diff options
-rw-r--r-- | src/libvdpau/nal_parser.c | 22 | ||||
-rw-r--r-- | src/libvdpau/vdpau_h264.c | 36 |
2 files changed, 33 insertions, 25 deletions
diff --git a/src/libvdpau/nal_parser.c b/src/libvdpau/nal_parser.c index 9bedae71d..d4c3af84d 100644 --- a/src/libvdpau/nal_parser.c +++ b/src/libvdpau/nal_parser.c @@ -831,14 +831,15 @@ int parse_frame(struct nal_parser *parser, uint8_t *inbuf, int inbuf_len, *ret_buf = NULL; return parsed_len; } - //if(parser->last_nal_res != 1) { - xine_fast_memcpy(&parser->buf[parser->buf_len], inbuf, next_nal+search_offset); - parser->buf_len += next_nal+search_offset; - //} + + xine_fast_memcpy(&parser->buf[parser->buf_len], inbuf, next_nal+search_offset); + parser->buf_len += next_nal+search_offset; + inbuf += next_nal+search_offset; parsed_len += next_nal+search_offset; - if((parser->last_nal_res = parse_nal(inbuf+4, inbuf_len-parsed_len, parser)) == 1 + parser->last_nal_res = parse_nal(inbuf+4, inbuf_len-parsed_len, parser); + if(parser->last_nal_res == 1 && parser->buf_len>0) { // parse_nal returned 1 --> detected a frame_boundary // do the extended parsing stuff... @@ -854,6 +855,9 @@ int parse_frame(struct nal_parser *parser, uint8_t *inbuf, int inbuf_len, parser->last_nal_res = 0; parser->slice_cnt = 0; return parsed_len; + } else if (parser->last_nal_res == 2) { + /* this is a nal_unit != SLICE, cut this out */ + parser->buf_len -= (next_nal+search_offset); } search_offset = 4; @@ -886,7 +890,6 @@ int parse_nal(uint8_t *buf, int buf_len, struct nal_parser *parser) struct nal_unit *last_nal = parser->last_nal; int res = parse_nal_header(&bufr, nal); - printf("type: %d\n", res); if(res == NAL_SLICE_IDR) parser->is_idr = 1; @@ -982,11 +985,10 @@ int parse_nal(uint8_t *buf, int buf_len, struct nal_parser *parser) return ret; } else if(res == NAL_PPS || res == NAL_SPS) { - return 0; - } else if (res == NAL_AU_DELIMITER || res == NAL_SEI || - (res >= 13 && res <= 18)) { + return 2; + } else if (res >= NAL_SEI) { //printf("New Frame\n"); - return 0; + return 2; } return 1; diff --git a/src/libvdpau/vdpau_h264.c b/src/libvdpau/vdpau_h264.c index 56f4d992d..4586c5afe 100644 --- a/src/libvdpau/vdpau_h264.c +++ b/src/libvdpau/vdpau_h264.c @@ -172,6 +172,7 @@ static void vdpau_h264_decode_data (video_decoder_t *this_gen, this->decoder_initialized = 1; img->free(img); + img = NULL; } if(this->decoder_initialized) { @@ -225,29 +226,33 @@ static void vdpau_h264_decode_data (video_decoder_t *this_gen, if(!this->decoder_started) this->decoder_started = 1; - VdpVideoSurface surface; - VdpStatus status = this->vdpau_accel->vdp_video_surface_create(this->vdpau_accel->vdp_device, - VDP_CHROMA_TYPE_420, this->width, this->height, - &surface); + if(img == NULL) { + img = this->stream->video_out->get_frame (this->stream->video_out, + this->width, this->height, + this->ratio, + XINE_IMGFMT_VDPAU, VO_BOTH_FIELDS); + this->vdpau_accel = (vdpau_accel_t*)img->accel_data; + } - if(status != VDP_STATUS_OK) - xprintf(this->xine, XINE_VERBOSITY_LOG, "vdpau_h264: Surface creation failed\n"); + VdpVideoSurface surface = this->vdpau_accel->surface; + + if(surface == VDP_INVALID_HANDLE) { + VdpStatus status = this->vdpau_accel->vdp_video_surface_create(this->vdpau_accel->vdp_device, + VDP_CHROMA_TYPE_420, this->width, this->height, + &surface); + this->vdpau_accel->surface = surface; + if(status != VDP_STATUS_OK) + xprintf(this->xine, XINE_VERBOSITY_LOG, "vdpau_h264: Surface creation failed\n"); + } printf("Decode: NUM: %d, REF: %d, BYTES: %d, PTS: %lld\n", pic.frame_num, pic.is_reference, vdp_buffer.bitstream_bytes, buf->pts); - status = this->vdpau_accel->vdp_decoder_render(this->decoder, + VdpStatus status = this->vdpau_accel->vdp_decoder_render(this->decoder, surface, (VdpPictureInfo*)&pic, 1, &vdp_buffer); if(status != VDP_STATUS_OK) xprintf(this->xine, XINE_VERBOSITY_LOG, "vdpau_h264: Decoder failure: %d\n", status); else { printf("DECODING SUCCESS\n"); - img = this->stream->video_out->get_frame (this->stream->video_out, - this->width, this->height, - this->ratio, - XINE_IMGFMT_VDPAU, VO_BOTH_FIELDS); - - this->vdpau_accel = (vdpau_accel_t*)img->accel_data; - this->vdpau_accel->surface = surface; img->duration = this->video_step; img->pts = buf->pts; @@ -255,9 +260,10 @@ static void vdpau_h264_decode_data (video_decoder_t *this_gen, img->draw(img, this->stream); img->free(img); + img = NULL; } - this->vdpau_accel->vdp_video_surface_destroy(surface); + //this->vdpau_accel->vdp_video_surface_destroy(surface); } } } |