summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulian Scheel <julian@jusst.de>2008-12-15 10:51:25 +0000
committerJulian Scheel <julian@jusst.de>2008-12-15 10:51:25 +0000
commit395b91f715127f3154476b1461622ab065d7bbf2 (patch)
tree0e7b16aaa3924e00ba67e366e471c74d2c8ed23e /src
parentff60558d1695c5c7ffc68b234b92fcde1f781dab (diff)
downloadxine-lib-395b91f715127f3154476b1461622ab065d7bbf2.tar.gz
xine-lib-395b91f715127f3154476b1461622ab065d7bbf2.tar.bz2
Reordering works for progressive.
Diffstat (limited to 'src')
-rw-r--r--src/libvdpau/dpb.c9
-rw-r--r--src/libvdpau/dpb.h2
-rw-r--r--src/libvdpau/h264_parser.c9
-rw-r--r--src/libvdpau/nal.h10
-rw-r--r--src/libvdpau/vdpau_h264.c30
5 files changed, 37 insertions, 23 deletions
diff --git a/src/libvdpau/dpb.c b/src/libvdpau/dpb.c
index 5afc93fb6..00f5dca0e 100644
--- a/src/libvdpau/dpb.c
+++ b/src/libvdpau/dpb.c
@@ -10,6 +10,7 @@
#include <string.h>
#include "dpb.h"
+#include "nal.h"
#include "video_out.h"
struct decoded_picture* init_decoded_picture(struct nal_unit *src_nal,
@@ -49,12 +50,11 @@ struct decoded_picture* dpb_get_next_out_picture(struct dpb *dpb)
do {
if (pic->delayed_output &&
(outpic == NULL ||
- pic->nal->top_field_order_cnt < outpic->nal->top_field_order_cnt))
+ pic->nal->top_field_order_cnt < outpic->nal->top_field_order_cnt ||
+ outpic->nal->nal_unit_type == NAL_SLICE_IDR))
outpic = pic;
} while ((pic = pic->next) != NULL);
- if(outpic)
- printf("OUTPUT: %lld\n", outpic->img->pts);
return outpic;
}
@@ -256,8 +256,9 @@ int dpb_add_picture(struct dpb *dpb, struct decoded_picture *pic, uint32_t num_r
i++;
if(i>num_ref_frames) {
pic->used_for_reference = 0;
- if(!pic->delayed_output)
+ if(!pic->delayed_output) {
dpb_remove_picture(dpb, pic);
+ }
pic = last_pic;
}
last_pic = pic;
diff --git a/src/libvdpau/dpb.h b/src/libvdpau/dpb.h
index d8586cd33..d76e47ee0 100644
--- a/src/libvdpau/dpb.h
+++ b/src/libvdpau/dpb.h
@@ -8,7 +8,7 @@
#ifndef DPB_H_
#define DPB_H_
-#define MAX_DPB_SIZE 10
+#define MAX_DPB_SIZE 16
#include "nal.h"
#include "video_out.h"
diff --git a/src/libvdpau/h264_parser.c b/src/libvdpau/h264_parser.c
index a70f965cd..9be736083 100644
--- a/src/libvdpau/h264_parser.c
+++ b/src/libvdpau/h264_parser.c
@@ -496,12 +496,11 @@ 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);
- sps->vui_parameters.time_scale = read_bits(buf, 32);
+ uint32_t num_units_in_tick = read_bits(buf, 32);
+ uint32_t time_scale = read_bits(buf, 32);
+ sps->vui_parameters.num_units_in_tick = num_units_in_tick;
+ sps->vui_parameters.time_scale = time_scale;
sps->vui_parameters.fixed_frame_rate_flag = read_bits(buf, 1);
- 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);
}
sps->vui_parameters.nal_hrd_parameters_present_flag = read_bits(buf, 1);
diff --git a/src/libvdpau/nal.h b/src/libvdpau/nal.h
index 30a38bf7c..351a3d84f 100644
--- a/src/libvdpau/nal.h
+++ b/src/libvdpau/nal.h
@@ -150,7 +150,7 @@ struct seq_parameter_set_rbsp
uint8_t vui_parameters_present_flag;
/* vui_parameters */
- union
+ struct
{
uint8_t aspect_ration_info_present_flag;
@@ -269,7 +269,7 @@ struct sei_message
uint32_t payload_size;
uint8_t last_payload_size_byte;
- union
+ struct
{
/* cpb_dpb_delays_present_flag == 1 */
uint8_t cpb_removal_delay;
@@ -309,7 +309,7 @@ struct slice_header
uint32_t num_ref_idx_l1_active_minus1;
/* ref_pic_list_reordering */
- union
+ struct
{
/* slice_type != I && slice_type != SI */
uint8_t ref_pic_list_reordering_flag_l0;
@@ -328,7 +328,7 @@ struct slice_header
} ref_pic_list_reordering;
/* pred_weight_table */
- union
+ struct
{
uint32_t luma_log2_weight_denom;
@@ -349,7 +349,7 @@ struct slice_header
} pred_weight_table;
/* def_rec_pic_marking */
- union
+ struct
{
/* nal_unit_type == NAL_SLICE_IDR */
diff --git a/src/libvdpau/vdpau_h264.c b/src/libvdpau/vdpau_h264.c
index 0d20bc89f..bb9d17c62 100644
--- a/src/libvdpau/vdpau_h264.c
+++ b/src/libvdpau/vdpau_h264.c
@@ -80,6 +80,7 @@ typedef struct vdpau_h264_decoder_s {
xine_t *xine;
int64_t last_pts;
+ int64_t last_idr_pts;
} vdpau_h264_decoder_t;
@@ -259,17 +260,24 @@ 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)
+ if(this->last_pts == 0)
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;
+ if(sps->vui_parameters_present_flag &&
+ sps->vui_parameters.timing_info_present_flag &&
+ this->video_step == 0) {
+ this->video_step = 90000/(1/((double)sps->vui_parameters.num_units_in_tick/(double)sps->vui_parameters.time_scale));
+ printf("Videostep: %d\n", this->video_step);
+ }
+
/* 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;
+ this->last_idr_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");
@@ -355,7 +363,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, this->last_pts);
+ printf("Decode: NUM: %d, REF: %d, BYTES: %d, PTS: %lld\n", pic.frame_num, pic.is_reference, vdp_buffer.bitstream_bytes, buf->pts);
VdpStatus status = this->vdpau_accel->vdp_decoder_render(this->decoder,
surface, (VdpPictureInfo*)&pic, 1, &vdp_buffer);
@@ -368,9 +376,8 @@ static void vdpau_h264_decode_data (video_decoder_t *this_gen,
xprintf(this->xine, XINE_VERBOSITY_LOG, "vdpau_h264: Decoder failure: %s\n", this->vdpau_accel->vdp_get_error_string(status));
else {
- img->duration = this->video_step;
- img->pts = this->last_pts;
- this->last_pts += this->video_step;
+ img->duration = (!slc->field_pic_flag*2)*this->video_step;
+ img->pts = 0;
img->bad_frame = 0;
struct decoded_picture *decoded_pic = NULL;
@@ -388,6 +395,7 @@ static void vdpau_h264_decode_data (video_decoder_t *this_gen,
}
}
+ printf("field_pic_flag: %d\n", slc->field_pic_flag);
if(!slc->field_pic_flag ||
(slc->field_pic_flag && slc->bottom_field_flag && this->wait_for_bottom_field)) {
if(!decoded_pic) {
@@ -402,7 +410,12 @@ static void vdpau_h264_decode_data (video_decoder_t *this_gen,
/* 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");
+ if(decoded_pic->nal->nal_unit_type == NAL_SLICE_IDR)
+ this->last_pts = this->last_idr_pts;
+
+ decoded_pic->img->pts = this->last_pts;
+ this->last_pts += (this->wait_for_bottom_field*2)*this->video_step;
+ printf("poc: %d, %d\n", decoded_pic->nal->top_field_order_cnt, decoded_pic->nal->bottom_field_order_cnt);
decoded_pic->img->draw(decoded_pic->img, this->stream);
dpb_set_output_picture(&(this->nal_parser->dpb), decoded_pic);
@@ -502,7 +515,8 @@ 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;
+ this->video_step = 0;
+ this->last_idr_pts = this->last_pts = 0;
return &this->video_decoder;
}