diff options
-rw-r--r-- | src/libvdpau/dpb.c | 7 | ||||
-rw-r--r-- | src/libvdpau/h264_parser.c | 56 | ||||
-rw-r--r-- | src/libvdpau/nal.c | 12 | ||||
-rw-r--r-- | src/libvdpau/vdpau_h264.c | 26 | ||||
-rw-r--r-- | src/video_out/video_out_vdpau.c | 3 |
5 files changed, 40 insertions, 64 deletions
diff --git a/src/libvdpau/dpb.c b/src/libvdpau/dpb.c index 7ad87bab7..561b1efa7 100644 --- a/src/libvdpau/dpb.c +++ b/src/libvdpau/dpb.c @@ -31,18 +31,15 @@ struct decoded_picture* init_decoded_picture(struct nal_unit *src_nal, VdpVideoSurface surface, vo_frame_t *img) { - struct decoded_picture *pic = malloc(sizeof(struct decoded_picture)); + struct decoded_picture *pic = calloc(1, sizeof(struct decoded_picture)); pic->nal = init_nal_unit(); copy_nal_unit(pic->nal, src_nal); - pic->used_for_reference = 0; - pic->delayed_output = 0; pic->top_is_reference = pic->nal->slc->field_pic_flag ? (pic->nal->slc->bottom_field_flag ? 0 : 1) : 1; pic->bottom_is_reference = pic->nal->slc->field_pic_flag ? (pic->nal->slc->bottom_field_flag ? 1 : 0) : 1; pic->surface = surface; pic->img = img; - pic->next = NULL; return pic; } @@ -51,6 +48,7 @@ void free_decoded_picture(struct decoded_picture *pic) { pic->img->free(pic->img); free_nal_unit(pic->nal); + free(pic); } struct decoded_picture* dpb_get_next_out_picture(struct dpb *dpb) @@ -315,6 +313,7 @@ void dpb_free_all( struct dpb *dpb ) } while (pic != NULL); printf("dpb_free_all, used: %d\n", dpb->used); + dpb->pictures = NULL; } int fill_vdpau_reference_list(struct dpb *dpb, VdpReferenceFrameH264 *reflist) diff --git a/src/libvdpau/h264_parser.c b/src/libvdpau/h264_parser.c index 03f906c77..bb2bad31e 100644 --- a/src/libvdpau/h264_parser.c +++ b/src/libvdpau/h264_parser.c @@ -102,12 +102,12 @@ 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) +static inline void dump_bits(uint32_t bits) { int i; printf("0b"); for(i=0; i < 32; i++) - printf("%d", (bits >> 31-i) & 0x01); + printf("%d", (bits >> (31-i)) & 0x01); printf("\n"); } @@ -213,9 +213,9 @@ int parse_nal_header(struct buf_reader *buf, struct nal_parser *parser) ibuf.cur_pos = ibuf.buf; if (!nal->sps) - nal->sps = malloc(sizeof(struct seq_parameter_set_rbsp)); - - memset(nal->sps, 0x00, sizeof(struct seq_parameter_set_rbsp)); + nal->sps = calloc(1, sizeof(struct seq_parameter_set_rbsp)); + else + memset(nal->sps, 0x00, sizeof(struct seq_parameter_set_rbsp)); parse_sps(&ibuf, parser); free(ibuf.buf); @@ -223,8 +223,9 @@ int parse_nal_header(struct buf_reader *buf, struct nal_parser *parser) break; case NAL_PPS: if (!nal->pps) - nal->pps = malloc(sizeof(struct pic_parameter_set_rbsp)); - memset(nal->pps, 0x00, sizeof(struct pic_parameter_set_rbsp)); + nal->pps = calloc(1, sizeof(struct pic_parameter_set_rbsp)); + else + memset(nal->pps, 0x00, sizeof(struct pic_parameter_set_rbsp)); parse_pps(buf, nal->pps, nal->sps); ret = NAL_PPS; @@ -236,9 +237,9 @@ int parse_nal_header(struct buf_reader *buf, struct nal_parser *parser) case NAL_SLICE_IDR: if (nal->sps && nal->pps) { if (!nal->slc) - nal->slc = malloc(sizeof(struct slice_header)); - - memset(nal->slc, 0x00, sizeof(struct slice_header)); + nal->slc = calloc(1, sizeof(struct slice_header)); + else + memset(nal->slc, 0x00, sizeof(struct slice_header)); parse_slice_header(buf, parser); ret = nal->nal_unit_type; @@ -1036,42 +1037,26 @@ void parse_dec_ref_pic_marking(struct buf_reader *buf, struct nal_parser* init_parser() { - struct nal_parser *parser = malloc(sizeof(struct nal_parser)); - memset(parser->buf, 0x00, MAX_FRAME_SIZE); - memset(parser->prebuf, 0x00, MAX_FRAME_SIZE); - parser->buf_len = 0; - parser->prebuf_len = 0; - parser->incomplete_nal = 0; - parser->next_nal_position = 0; - - parser->found_sps = 0; - parser->found_pps = 0; + struct nal_parser *parser = calloc(1, sizeof(struct nal_parser)); parser->nal0 = init_nal_unit(); parser->nal1 = init_nal_unit(); parser->current_nal = parser->nal0; parser->last_nal = parser->nal1; - parser->last_nal_res = 0; - parser->is_idr = 0; - parser->slice = 0; - parser->slice_cnt = 0; parser->field = -1; - parser->have_top = 0; /* no idea why we do that. inspired by libavcodec, * as we couldn't figure in the specs.... */ parser->prev_pic_order_cnt_msb = parser->pic_order_cnt_lsb = 1 << 16; - parser->cpb_dpb_delays_present_flag = 0; - return parser; } void free_parser(struct nal_parser *parser) { - free(parser->nal0); - free(parser->nal1); + free_nal_unit(parser->nal0); + free_nal_unit(parser->nal1); free(parser); } @@ -1312,10 +1297,15 @@ int parse_nal(uint8_t *buf, int buf_len, struct nal_parser *parser) parser->last_nal = parser->nal1; } - if (parser->current_nal->sps == NULL) - parser->current_nal->sps = parser->last_nal->sps; - if (parser->current_nal->pps == NULL) - parser->current_nal->pps = parser->last_nal->pps; + if(!parser->current_nal->sps && parser->last_nal->sps) { + parser->current_nal->sps = malloc(sizeof(struct seq_parameter_set_rbsp)); + xine_fast_memcpy(parser->current_nal->sps, parser->last_nal->sps, sizeof(struct seq_parameter_set_rbsp)); + } + + if(!parser->current_nal->pps && parser->last_nal->pps) { + parser->current_nal->pps = malloc(sizeof(struct pic_parameter_set_rbsp)); + xine_fast_memcpy(parser->current_nal->pps, parser->last_nal->pps, sizeof(struct pic_parameter_set_rbsp)); + } /* increase the slice_cnt until a new frame is detected */ if (!ret) diff --git a/src/libvdpau/nal.c b/src/libvdpau/nal.c index 608f082c0..eaa32c700 100644 --- a/src/libvdpau/nal.c +++ b/src/libvdpau/nal.c @@ -29,15 +29,11 @@ struct nal_unit* init_nal_unit() { - struct nal_unit *nal = malloc(sizeof(struct nal_unit)); - memset(nal, 0x00, sizeof(struct nal_unit)); + struct nal_unit *nal = calloc(1, sizeof(struct nal_unit)); - /*nal->sps = malloc(sizeof(struct seq_parameter_set_rbsp)); - memset(nal->sps, 0x00, sizeof(struct seq_parameter_set_rbsp)); - nal->pps = malloc(sizeof(struct pic_parameter_set_rbsp)); - memset(nal->pps, 0x00, sizeof(struct pic_parameter_set_rbsp)); - nal->slc = malloc(sizeof(struct slice_header)); - memset(nal->slc, 0x00, sizeof(struct slice_header));*/ + /*nal->sps = calloc(1, sizeof(struct seq_parameter_set_rbsp)); + nal->pps = calloc(1, sizeof(struct pic_parameter_set_rbsp)); + nal->slc = calloc(1, sizeof(struct slice_header));*/ return nal; } diff --git a/src/libvdpau/vdpau_h264.c b/src/libvdpau/vdpau_h264.c index 2fe2591e1..5ba905ade 100644 --- a/src/libvdpau/vdpau_h264.c +++ b/src/libvdpau/vdpau_h264.c @@ -328,6 +328,7 @@ static void vdpau_h264_decode_data (video_decoder_t *this_gen, ref_frames = 16; } + printf("Allocate %d reference frames\n", ref_frames); /* get the vdpau context from vo */ //(this->stream->video_out->open) (this->stream->video_out, this->stream); img = this->stream->video_out->get_frame (this->stream->video_out, @@ -468,10 +469,8 @@ static void vdpau_h264_decode_data (video_decoder_t *this_gen, if(status != VDP_STATUS_OK) { xprintf(this->xine, XINE_VERBOSITY_LOG, "vdpau_h264: Decoder failure: %s\n", this->vdpau_accel->vdp_get_error_string(status)); - img->bad_frame = 1; - img->draw(img, this->stream); - this->last_img = NULL; - this->dangling_img = NULL; + img->free(img); + img = this->last_img = this->dangling_img = NULL; } else { img->bad_frame = 0; @@ -517,8 +516,7 @@ static void vdpau_h264_decode_data (video_decoder_t *this_gen, this->last_img = img = NULL; /* now retrieve the next output frame */ - decoded_pic = dpb_get_next_out_picture(&(this->nal_parser->dpb)); - if(decoded_pic) { + if ((decoded_pic = dpb_get_next_out_picture(&(this->nal_parser->dpb))) != NULL) { decoded_pic->img->top_field_first = (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); @@ -561,6 +559,8 @@ static void vdpau_h264_reset (video_decoder_t *this_gen) { if (this->decoder_initialized) this->vdpau_accel->vdp_decoder_destroy( this->decoder ); + free_parser(this->nal_parser); + this->decoder_started = 0; this->decoder_initialized = 0; this->nal_parser = init_parser(); @@ -613,7 +613,7 @@ static void vdpau_h264_dispose (video_decoder_t *this_gen) { this->stream->video_out->close( this->stream->video_out, this->stream ); - free (this->nal_parser); + free_parser (this->nal_parser); free (this_gen); } @@ -636,24 +636,12 @@ static video_decoder_t *open_plugin (video_decoder_class_t *class_gen, xine_stre this->video_decoder.reset = vdpau_h264_reset; this->video_decoder.discontinuity = vdpau_h264_discontinuity; this->video_decoder.dispose = vdpau_h264_dispose; - this->size = 0; this->stream = stream; this->xine = stream->xine; this->class = (vdpau_h264_class_t *) class_gen; - this->decoder_started = 0; - this->decoder_initialized = 0; this->nal_parser = init_parser(); - this->buf = NULL; - this->wait_for_bottom_field = 0; - this->video_step = 0; - this->curr_pts = 0; - this->next_pts = 0; - - this->last_img = NULL; - this->dangling_img = NULL; - this->width = this->height = 0; (this->stream->video_out->open) (this->stream->video_out, this->stream); diff --git a/src/video_out/video_out_vdpau.c b/src/video_out/video_out_vdpau.c index 33dd0f717..4009b08d1 100644 --- a/src/video_out/video_out_vdpau.c +++ b/src/video_out/video_out_vdpau.c @@ -1178,6 +1178,7 @@ static void vdpau_dispose (vo_driver_t *this_gen) vdpau_driver_t *this = (vdpau_driver_t *) this_gen; int i; + this->ovl_yuv2rgb->dispose(this->ovl_yuv2rgb); this->yuv2rgb_factory->dispose (this->yuv2rgb_factory); for ( i=0; i<XINE_VORAW_MAX_OVL; ++i ) { @@ -1185,6 +1186,8 @@ static void vdpau_dispose (vo_driver_t *this_gen) vdp_bitmap_destroy( this->overlays[i].ovl_bitmap ); } + if ( this->video_mixer!=VDP_INVALID_HANDLE ) + vdp_video_mixer_destroy( this->video_mixer ); if ( this->overlay_unscaled!=VDP_INVALID_HANDLE ) vdp_output_surface_destroy( this->overlay_unscaled ); if ( this->overlay_output!=VDP_INVALID_HANDLE ) |