summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulian Scheel <julian@jusst.de>2008-12-15 08:14:02 +0000
committerJulian Scheel <julian@jusst.de>2008-12-15 08:14:02 +0000
commit4ad3c69c9557f7a4385c549556ef3f1bf08740b5 (patch)
tree5597c88563eef3f652c881577f24cea3e0761d00 /src
parent28ed70dae3b5736d904d704e76b64e039a459f81 (diff)
downloadxine-lib-4ad3c69c9557f7a4385c549556ef3f1bf08740b5.tar.gz
xine-lib-4ad3c69c9557f7a4385c549556ef3f1bf08740b5.tar.bz2
Testing.
Diffstat (limited to 'src')
-rw-r--r--src/libvdpau/dpb.c34
-rw-r--r--src/libvdpau/h264_parser.c21
-rw-r--r--src/libvdpau/nal.h23
-rw-r--r--src/libvdpau/vdpau_h264.c4
4 files changed, 72 insertions, 10 deletions
diff --git a/src/libvdpau/dpb.c b/src/libvdpau/dpb.c
index 00dd1a580..bbcfe4a9d 100644
--- a/src/libvdpau/dpb.c
+++ b/src/libvdpau/dpb.c
@@ -47,7 +47,7 @@ struct decoded_picture* dpb_get_next_out_picture(struct dpb *dpb)
if (pic != NULL)
do {
- if (pic->img->pts < outpic->img->pts)
+ if (pic->nal->top_field_order_cnt < outpic->nal->top_field_order_cnt)
outpic = pic;
} while ((pic = pic->next) != NULL);
@@ -97,6 +97,22 @@ struct decoded_picture* dpb_get_picture_by_ltidx(struct dpb *dpb,
return NULL;
}
+int dpb_set_unused_ref_picture_a(struct dpb *dpb, struct decoded_picture *refpic)
+{
+ struct decoded_picture *pic = dpb->pictures;
+ if (pic != NULL)
+ do {
+ if (pic == refpic) {
+ pic->used_for_reference = 0;
+ if(!pic->delayed_output)
+ dpb_remove_picture(dpb, pic);
+ return 0;
+ }
+ } while ((pic = pic->next) != NULL);
+
+ return -1;
+}
+
int dpb_set_unused_ref_picture(struct dpb *dpb, uint32_t picnum)
{
struct decoded_picture *pic = dpb->pictures;
@@ -256,14 +272,14 @@ int dpb_flush(struct dpb *dpb)
if (pic != NULL)
do {
- dpb->pictures = pic->next;
- free_decoded_picture(pic);
- pic = dpb->pictures;
- dpb->used--;
- } while (dpb->pictures != NULL);
-
- dpb->pictures = NULL;
- dpb->used = 0;
+ struct decoded_picture *next_pic = pic->next;
+ dpb_set_unused_ref_picture_a(dpb, pic);
+ pic = next_pic;
+ } while (pic != NULL);
+
+ printf("Flushed, used: %d\n", dpb->used);
+ //dpb->pictures = NULL;
+ //dpb->used = 0;
return 0;
}
diff --git a/src/libvdpau/h264_parser.c b/src/libvdpau/h264_parser.c
index 28f9f607f..2e27bd4aa 100644
--- a/src/libvdpau/h264_parser.c
+++ b/src/libvdpau/h264_parser.c
@@ -78,6 +78,15 @@ static void decode_nal(uint8_t **ret, int *len_ret, uint8_t *buf, int buf_len)
*len_ret = pos - *ret;
}
+static inline dump_bits(uint32_t bits)
+{
+ int i;
+ printf("0b");
+ for(i=0; i < 32; i++)
+ printf("%d", (bits >> 31-i) & 0x01);
+ printf("\n");
+}
+
static inline uint32_t read_bits(struct buf_reader *buf, int len)
{
static uint32_t i_mask[33] = { 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f,
@@ -97,10 +106,12 @@ static inline uint32_t read_bits(struct buf_reader *buf, int len)
buf->cur_pos++;
buf->cur_offset = 8;
}
+ //dump_bits(bits);
return bits;
}
else {
bits |= (*buf->cur_pos & i_mask[buf->cur_offset]) << -i_shr;
+ //dump_bits(bits);
len -= buf->cur_offset;
buf->cur_pos++;
buf->cur_offset = 8;
@@ -452,6 +463,7 @@ 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);
@@ -485,8 +497,16 @@ 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);
}
sps->vui_parameters.nal_hrd_parameters_present_flag = read_bits(buf, 1);
@@ -630,6 +650,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);
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) {
diff --git a/src/libvdpau/nal.h b/src/libvdpau/nal.h
index 20c1c32dc..30a38bf7c 100644
--- a/src/libvdpau/nal.h
+++ b/src/libvdpau/nal.h
@@ -63,6 +63,29 @@ static inline uint32_t slice_type(uint32_t slice_type)
return (slice_type < 10 ? slice_type % 5 : slice_type);
}
+static inline void print_slice_type(uint32_t slice_type)
+{
+ switch(slice_type) {
+ case SLICE_P:
+ printf("SLICE_P\n");
+ break;
+ case SLICE_B:
+ printf("SLICE_B\n");
+ break;
+ case SLICE_I:
+ printf("SLICE_I\n");
+ break;
+ case SLICE_SP:
+ printf("SLICE_SP\n");
+ break;
+ case SLICE_SI:
+ printf("SLICE_SI\n");
+ break;
+ default:
+ printf("Unknown SLICE\n");
+ }
+}
+
struct hrd_parameters
{
uint32_t cpb_cnt_minus1;
diff --git a/src/libvdpau/vdpau_h264.c b/src/libvdpau/vdpau_h264.c
index a4446d109..5535a48ae 100644
--- a/src/libvdpau/vdpau_h264.c
+++ b/src/libvdpau/vdpau_h264.c
@@ -79,6 +79,8 @@ typedef struct vdpau_h264_decoder_s {
xine_t *xine;
+ int64_t last_pts;
+
} vdpau_h264_decoder_t;
/**************************************************************************
@@ -266,6 +268,7 @@ static void vdpau_h264_decode_data (video_decoder_t *this_gen,
printf("IDR Slice, flush\n");
dpb_flush(&(this->nal_parser->dpb));
printf("Emtpy: %s", this->nal_parser->dpb.pictures == NULL ? "Yes" : "No");
+ this->last_pts = buf->pts;
}
this->nal_parser->is_idr = 0;
@@ -402,7 +405,6 @@ static void vdpau_h264_decode_data (video_decoder_t *this_gen,
this->wait_for_bottom_field = 0;*/
- printf("pts: %lld\n", buf->pts);
img->draw(img, this->stream);
this->wait_for_bottom_field = 0;