summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libvdpau/dpb.c6
-rw-r--r--src/libvdpau/h264_parser.c13
-rw-r--r--src/libvdpau/vdpau_h264.c21
3 files changed, 22 insertions, 18 deletions
diff --git a/src/libvdpau/dpb.c b/src/libvdpau/dpb.c
index bbcfe4a9d..5afc93fb6 100644
--- a/src/libvdpau/dpb.c
+++ b/src/libvdpau/dpb.c
@@ -40,14 +40,16 @@ void free_decoded_picture(struct decoded_picture *pic)
struct decoded_picture* dpb_get_next_out_picture(struct dpb *dpb)
{
struct decoded_picture *pic = dpb->pictures;
- struct decoded_picture *outpic = pic;
+ struct decoded_picture *outpic = NULL;
if(dpb->used < MAX_DPB_SIZE)
return NULL;
if (pic != NULL)
do {
- if (pic->nal->top_field_order_cnt < outpic->nal->top_field_order_cnt)
+ if (pic->delayed_output &&
+ (outpic == NULL ||
+ pic->nal->top_field_order_cnt < outpic->nal->top_field_order_cnt))
outpic = pic;
} while ((pic = pic->next) != NULL);
diff --git a/src/libvdpau/h264_parser.c b/src/libvdpau/h264_parser.c
index 2e27bd4aa..a70f965cd 100644
--- a/src/libvdpau/h264_parser.c
+++ b/src/libvdpau/h264_parser.c
@@ -388,6 +388,7 @@ uint8_t parse_sps(struct buf_reader *buf, struct nal_parser *parser)
sps->offset_for_ref_frame[i] = read_exp_golomb_s(buf);
}
}
+
sps->num_ref_frames = read_exp_golomb(buf);
sps->gaps_in_frame_num_value_allowed_flag = read_bits(buf, 1);
@@ -463,7 +464,6 @@ void parse_vui_parameters(struct buf_reader *buf,
sps->vui_parameters.aspect_ration_info_present_flag = read_bits(buf, 1);
if (sps->vui_parameters.aspect_ration_info_present_flag == 1) {
sps->vui_parameters.aspect_ratio_idc = read_bits(buf, 8);
- printf("Aspect idc: %d\n", sps->vui_parameters.aspect_ratio_idc);
if (sps->vui_parameters.aspect_ratio_idc == ASPECT_RESERVED) {
sps->vui_parameters.sar_width = read_bits(buf, 16);
sps->vui_parameters.sar_height = read_bits(buf, 16);
@@ -497,13 +497,8 @@ void parse_vui_parameters(struct buf_reader *buf,
sps->vui_parameters.timing_info_present_flag = read_bits(buf, 1);
if (sps->vui_parameters.timing_info_present_flag) {
sps->vui_parameters.num_units_in_tick = read_bits(buf, 32);
- printf("Framerate\n");
sps->vui_parameters.time_scale = read_bits(buf, 32);
- printf("Time scale: %d\n", sps->vui_parameters.time_scale);
- printf("Time scale: %d\n", sps->vui_parameters.time_scale);
sps->vui_parameters.fixed_frame_rate_flag = read_bits(buf, 1);
- printf("Time scale: %d\n", sps->vui_parameters.time_scale);
- printf("Framerate fixed: %d\n", sps->vui_parameters.fixed_frame_rate_flag);
printf("Framerate: %d/%d = %f\n", sps->vui_parameters.num_units_in_tick,
sps->vui_parameters.time_scale,
(double)sps->vui_parameters.num_units_in_tick/(double)sps->vui_parameters.time_scale);
@@ -650,7 +645,7 @@ uint8_t parse_slice_header(struct buf_reader *buf, struct nal_parser *parser)
slc->first_mb_in_slice = read_exp_golomb(buf);
/* we do some parsing on the slice type, because the list is doubled */
slc->slice_type = slice_type(read_exp_golomb(buf));
- print_slice_type(slc->slice_type);
+ //print_slice_type(slc->slice_type);
slc->pic_parameter_set_id = read_exp_golomb(buf);
slc->frame_num = read_bits(buf, sps->log2_max_frame_num_minus4 + 4);
if (!sps->frame_mbs_only_flag) {
@@ -1072,8 +1067,6 @@ int parse_frame(struct nal_parser *parser, uint8_t *inbuf, int inbuf_len,
*ret_len = parser->buf_len;
*ret_slice_cnt = parser->slice_cnt;
- calculate_pic_order(parser);
-
//memset(parser->buf, 0x00, parser->buf_len);
parser->buf_len = 0;
parser->last_nal_res = 1;
@@ -1170,6 +1163,8 @@ int parse_nal(uint8_t *buf, int buf_len, struct nal_parser *parser)
parser->is_idr = 1;
}
+ calculate_pic_order(parser);
+
if (res >= NAL_SLICE && res <= NAL_SLICE_IDR) {
// now detect if it's a new frame!
int ret = 0;
diff --git a/src/libvdpau/vdpau_h264.c b/src/libvdpau/vdpau_h264.c
index 5535a48ae..0d20bc89f 100644
--- a/src/libvdpau/vdpau_h264.c
+++ b/src/libvdpau/vdpau_h264.c
@@ -183,6 +183,7 @@ static void vdpau_h264_decode_data (video_decoder_t *this_gen,
if (buf->decoder_flags & BUF_FLAG_FRAMERATE) {
this->video_step = buf->decoder_info[0];
+ printf("Videostep: %lld\n", this->video_step);
_x_stream_info_set(this->stream, XINE_STREAM_INFO_FRAME_DURATION, this->video_step);
}
@@ -258,6 +259,9 @@ static void vdpau_h264_decode_data (video_decoder_t *this_gen,
this->nal_parser->current_nal->sps != NULL &&
this->nal_parser->current_nal->pps != NULL) {
+ if(this->last_pts = -1)
+ this->last_pts = buf->pts;
+
struct pic_parameter_set_rbsp *pps = this->nal_parser->current_nal->pps;
struct seq_parameter_set_rbsp *sps = this->nal_parser->current_nal->sps;
struct slice_header *slc = this->nal_parser->current_nal->slc;
@@ -265,6 +269,7 @@ static void vdpau_h264_decode_data (video_decoder_t *this_gen,
/* flush the DPB if this frame was an IDR */
//printf("is_idr: %d\n", this->nal_parser->is_idr);
if(this->nal_parser->current_nal->nal_unit_type == NAL_SLICE_IDR) {
+ this->last_pts = buf->pts;
printf("IDR Slice, flush\n");
dpb_flush(&(this->nal_parser->dpb));
printf("Emtpy: %s", this->nal_parser->dpb.pictures == NULL ? "Yes" : "No");
@@ -350,7 +355,7 @@ static void vdpau_h264_decode_data (video_decoder_t *this_gen,
xprintf(this->xine, XINE_VERBOSITY_LOG, "vdpau_h264: Surface creation failed: %s\n", this->vdpau_accel->vdp_get_error_string(status));
}
- printf("Decode: NUM: %d, REF: %d, BYTES: %d, PTS: %lld\n", pic.frame_num, pic.is_reference, vdp_buffer.bitstream_bytes, buf->pts);
+ printf("Decode: NUM: %d, REF: %d, BYTES: %d, PTS: %lld\n", pic.frame_num, pic.is_reference, vdp_buffer.bitstream_bytes, this->last_pts);
VdpStatus status = this->vdpau_accel->vdp_decoder_render(this->decoder,
surface, (VdpPictureInfo*)&pic, 1, &vdp_buffer);
@@ -364,7 +369,8 @@ static void vdpau_h264_decode_data (video_decoder_t *this_gen,
else {
img->duration = this->video_step;
- img->pts = buf->pts;
+ img->pts = this->last_pts;
+ this->last_pts += this->video_step;
img->bad_frame = 0;
struct decoded_picture *decoded_pic = NULL;
@@ -384,7 +390,7 @@ static void vdpau_h264_decode_data (video_decoder_t *this_gen,
if(!slc->field_pic_flag ||
(slc->field_pic_flag && slc->bottom_field_flag && this->wait_for_bottom_field)) {
- /*if(!decoded_pic) {
+ if(!decoded_pic) {
decoded_pic = init_decoded_picture(this->nal_parser->current_nal, surface, img);
decoded_pic->delayed_output = 1;
dpb_add_picture(&(this->nal_parser->dpb), decoded_pic, sps->num_ref_frames);
@@ -393,7 +399,7 @@ static void vdpau_h264_decode_data (video_decoder_t *this_gen,
img = NULL;
- / * now retrieve the next output frame * /
+ /* now retrieve the next output frame */
decoded_pic = dpb_get_next_out_picture(&(this->nal_parser->dpb));
if(decoded_pic) {
printf("DRAW AN IMAGE\n");
@@ -403,14 +409,14 @@ static void vdpau_h264_decode_data (video_decoder_t *this_gen,
} else
printf("NO IMAGE THIS TIME\n");
- this->wait_for_bottom_field = 0;*/
+ this->wait_for_bottom_field = 0;
- img->draw(img, this->stream);
+ /*img->draw(img, this->stream);
this->wait_for_bottom_field = 0;
if(!pic.is_reference)
img->free(img);
- img = NULL;
+ img = NULL;*/
} else if(slc->field_pic_flag && !slc->bottom_field_flag) {
// don't draw yet, second field is missing.
this->wait_for_bottom_field = 1;
@@ -496,6 +502,7 @@ static video_decoder_t *open_plugin (video_decoder_class_t *class_gen, xine_stre
this->nal_parser = init_parser();
this->buf = NULL;
this->wait_for_bottom_field = 0;
+ this->video_step = 1800;
return &this->video_decoder;
}