diff options
Diffstat (limited to 'src/libvdpau')
-rw-r--r-- | src/libvdpau/h264_parser.c | 2 | ||||
-rw-r--r-- | src/libvdpau/vdpau_h264.c | 58 | ||||
-rw-r--r-- | src/libvdpau/vdpau_mpeg12.c | 14 |
3 files changed, 56 insertions, 18 deletions
diff --git a/src/libvdpau/h264_parser.c b/src/libvdpau/h264_parser.c index fcec0b92e..dff73f235 100644 --- a/src/libvdpau/h264_parser.c +++ b/src/libvdpau/h264_parser.c @@ -1139,7 +1139,7 @@ int parse_frame(struct nal_parser *parser, uint8_t *inbuf, int inbuf_len, parser->last_nal_res = parse_nal(prebuf+3, parser->prebuf_len-3, parser); if (parser->last_nal_res == 1 && parser->buf_len > 0) { - //printf("Frame complete: %d bytes\n", parser->buf_len); + printf("Frame complete: %d bytes\n", parser->buf_len); *ret_buf = malloc(parser->buf_len); xine_fast_memcpy(*ret_buf, parser->buf, parser->buf_len); *ret_len = parser->buf_len; diff --git a/src/libvdpau/vdpau_h264.c b/src/libvdpau/vdpau_h264.c index 0f6639125..ca9407063 100644 --- a/src/libvdpau/vdpau_h264.c +++ b/src/libvdpau/vdpau_h264.c @@ -82,6 +82,8 @@ typedef struct vdpau_h264_decoder_s { vo_frame_t *last_img; vo_frame_t *dangling_img; + int vdp_runtime_nr; + } vdpau_h264_decoder_t; /************************************************************************** @@ -186,7 +188,6 @@ static void vdpau_h264_decode_data (video_decoder_t *this_gen, this->video_step = buf->decoder_info[0]; _x_stream_info_set(this->stream, XINE_STREAM_INFO_FRAME_DURATION, this->video_step); } - if (buf->decoder_flags & BUF_FLAG_STDHEADER) { /* need to initialize */ xine_bmiheader *bih = (xine_bmiheader*)buf->content; this->width = bih->biWidth; @@ -196,14 +197,17 @@ static void vdpau_h264_decode_data (video_decoder_t *this_gen, /* parse the first nal packages to retrieve profile type */ int len = 0; + int write_start_seq = 0; uint32_t slice_count; if(buf->pts != 0) this->next_pts = buf->pts; - while(len < buf->size) { - len += parse_frame(this->nal_parser, buf->content + len, buf->size - len, - (void*)&vdp_buffer.bitstream, &vdp_buffer.bitstream_bytes, &slice_count); + while(len < buf->size || write_start_seq == 1) { + if(!write_start_seq) { + len += parse_frame(this->nal_parser, buf->content + len, buf->size - len, + (void*)&vdp_buffer.bitstream, &vdp_buffer.bitstream_bytes, &slice_count); + } if(!this->decoder_initialized && this->nal_parser->current_nal != NULL && @@ -340,18 +344,19 @@ static void vdpau_h264_decode_data (video_decoder_t *this_gen, /*VdpBool is_supported; uint32_t max_level, max_references, max_width, max_height;*/ - xprintf(this->xine, XINE_VERBOSITY_LOG, - "Create decoder: vdp_device: %d, profile: %d, res: %dx%d\n", - this->vdpau_accel->vdp_device, this->profile, this->width, this->height); - - VdpStatus status = this->vdpau_accel->vdp_decoder_create(this->vdpau_accel->vdp_device, - this->profile, this->width, this->height, 16, &this->decoder); - - if(status != VDP_STATUS_OK) - xprintf(this->xine, XINE_VERBOSITY_LOG, "vdpau_h264: ERROR: VdpDecoderCreate returned status != OK (%s)\n", this->vdpau_accel->vdp_get_error_string(status)); - else - this->decoder_initialized = 1; - + if(this->vdpau_accel->vdp_runtime_nr > 0) { + xprintf(this->xine, XINE_VERBOSITY_LOG, + "Create decoder: vdp_device: %d, profile: %d, res: %dx%d\n", + this->vdpau_accel->vdp_device, this->profile, this->width, this->height); + + VdpStatus status = this->vdpau_accel->vdp_decoder_create(this->vdpau_accel->vdp_device, + this->profile, this->width, this->height, 16, &this->decoder); + + if(status != VDP_STATUS_OK) + xprintf(this->xine, XINE_VERBOSITY_LOG, "vdpau_h264: ERROR: VdpDecoderCreate returned status != OK (%s)\n", this->vdpau_accel->vdp_get_error_string(status)); + else + this->decoder_initialized = 1; + } img->free(img); img = NULL; } @@ -361,7 +366,6 @@ static void vdpau_h264_decode_data (video_decoder_t *this_gen, this->nal_parser->current_nal->slc != NULL && this->nal_parser->current_nal->sps != NULL && this->nal_parser->current_nal->pps != NULL) { - 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; @@ -452,6 +456,23 @@ static void vdpau_h264_decode_data (video_decoder_t *this_gen, this->dangling_img = img; } + if(this->vdp_runtime_nr != *(this->vdpau_accel->current_vdp_runtime_nr)) { + printf("VDPAU was preempted. Reinitialise the decoder.\n"); + this->decoder_initialized = 0; + this->decoder_started = 0; + this->vdp_runtime_nr = this->vdpau_accel->vdp_runtime_nr; + this->last_img = NULL; + this->last_ref_pic = NULL; + dpb_free_all(&this->nal_parser->dpb); + free_parser(this->nal_parser); + this->nal_parser = init_parser(); + if(img) { + img->free(img); + img = NULL; + } + continue; + } + VdpVideoSurface surface = this->vdpau_accel->surface; //printf("Decode: NUM: %d, REF: %d, BYTES: %d, PTS: %lld\n", pic.frame_num, pic.is_reference, vdp_buffer.bitstream_bytes, this->curr_pts); @@ -543,6 +564,7 @@ static void vdpau_h264_decode_data (video_decoder_t *this_gen, } } } + } } @@ -649,6 +671,8 @@ static video_decoder_t *open_plugin (video_decoder_class_t *class_gen, xine_stre this->xine = stream->xine; this->class = (vdpau_h264_class_t *) class_gen; + this->vdp_runtime_nr = 1; + this->nal_parser = init_parser(); (this->stream->video_out->open) (this->stream->video_out, this->stream); diff --git a/src/libvdpau/vdpau_mpeg12.c b/src/libvdpau/vdpau_mpeg12.c index 7978a7682..819796d0f 100644 --- a/src/libvdpau/vdpau_mpeg12.c +++ b/src/libvdpau/vdpau_mpeg12.c @@ -143,6 +143,8 @@ typedef struct { vdpau_accel_t *accel_vdpau; + int vdp_runtime_nr; + } sequence_t; @@ -578,6 +580,7 @@ static void decode_render( vdpau_mpeg12_decoder_t *vd, vdpau_accel_t *accel ) vd->decoder_profile = seq->profile; vd->decoder_width = seq->coded_width; vd->decoder_height = seq->coded_height; + seq->vdp_runtime_nr = accel->vdp_runtime_nr; } } @@ -671,6 +674,16 @@ static void decode_picture( vdpau_mpeg12_decoder_t *vd ) if ( !seq->accel_vdpau ) seq->accel_vdpau = accel; + if( seq->vdp_runtime_nr != *(seq->accel_vdpau->current_vdp_runtime_nr) ) { + seq->accel_vdpau = accel; + if ( seq->forward_ref ) + seq->forward_ref->free( seq->forward_ref ); + seq->forward_ref = NULL; + if ( seq->backward_ref ) + seq->backward_ref->free( seq->backward_ref ); + seq->backward_ref = NULL; + vd->decoder = VDP_INVALID_HANDLE; + } img->drawn = 0; //printf("vdpau_mpeg12: .. got image %d\n", img); @@ -870,6 +883,7 @@ static video_decoder_t *open_plugin (video_decoder_class_t *class_gen, xine_stre this->sequence.buf = (uint8_t*)malloc(this->sequence.bufsize); this->sequence.forward_ref = 0; this->sequence.backward_ref = 0; + this->sequence.vdp_runtime_nr = 1; reset_sequence( &this->sequence ); init_picture( &this->sequence.picture ); |