Original patch by NVIDIA corporation. Originally committed as revision 20502 to svn://svn.ffmpeg.org/ffmpeg/trunk
Unified · Split
| @@ -1131,6 +1131,8 @@ mpeg2_vaapi_hwaccel_deps="va_va_h" · 1130 unmodified lines | ||
| 1131 | 1131 | mpeg2_vaapi_hwaccel_select="vaapi mpeg2video_decoder" |
| 1132 | 1132 | mpeg4_vaapi_hwaccel_deps="va_va_h" |
| 1133 | 1133 | mpeg4_vaapi_hwaccel_select="vaapi mpeg4_decoder" |
| 1134 | +mpeg4_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h" | |
| 1135 | +mpeg4_vdpau_decoder_select="vdpau mpeg4_decoder" | |
| 1134 | 1136 | mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h" |
| 1135 | 1137 | mpeg_xvmc_decoder_select="mpegvideo_decoder" |
| 1136 | 1138 | msmpeg4v1_encoder_select="h263_encoder" |
| @@ -123,6 +123,7 @@ void avcodec_register_all(void) · 122 unmodified lines | ||
| 123 | 123 | REGISTER_ENCDEC (MPEG1VIDEO, mpeg1video); |
| 124 | 124 | REGISTER_ENCDEC (MPEG2VIDEO, mpeg2video); |
| 125 | 125 | REGISTER_ENCDEC (MPEG4, mpeg4); |
| 126 | + REGISTER_DECODER (MPEG4_VDPAU, mpeg4_vdpau); | |
| 126 | 127 | REGISTER_DECODER (MPEGVIDEO, mpegvideo); |
| 127 | 128 | REGISTER_DECODER (MPEG_VDPAU, mpeg_vdpau); |
| 128 | 129 | REGISTER_DECODER (MPEG1_VDPAU, mpeg1_vdpau); |
| @@ -32,6 +32,7 @@ · 31 unmodified lines | ||
| 32 | 32 | #include "h263_parser.h" |
| 33 | 33 | #include "mpeg4video_parser.h" |
| 34 | 34 | #include "msmpeg4.h" |
| 35 | +#include "vdpau_internal.h" | |
| 35 | 36 | |
| 36 | 37 | //#define DEBUG |
| 37 | 38 | //#define PRINT_FRAME_TIME |
| @@ -621,6 +622,11 @@ retry: · 583 unmodified lines | ||
| 621 | 622 | if(MPV_frame_start(s, avctx) < 0) |
| 622 | 623 | return -1; |
| 623 | 624 | |
| 625 | + if (CONFIG_MPEG4_VDPAU_DECODER && (s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)) { | |
| 626 | + ff_vdpau_mpeg4_decode_picture(s, buf, buf_size); | |
| 627 | + goto frame_end; | |
| 628 | + } | |
| 629 | + | |
| 624 | 630 | if (avctx->hwaccel) { |
| 625 | 631 | if (avctx->hwaccel->start_frame(avctx, buf, buf_size) < 0) |
| 626 | 632 | return -1; |
| @@ -695,6 +701,7 @@ retry: · 68 unmodified lines | ||
| 695 | 701 | intrax8_decoded: |
| 696 | 702 | ff_er_frame_end(s); |
| 697 | 703 | |
| 704 | +frame_end: | |
| 698 | 705 | if (avctx->hwaccel) { |
| 699 | 706 | if (avctx->hwaccel->end_frame(avctx) < 0) |
| 700 | 707 | return -1; |
| @@ -835,3 +842,19 @@ AVCodec flv_decoder = { · 134 unmodified lines | ||
| 835 | 842 | .long_name= NULL_IF_CONFIG_SMALL("Flash Video (FLV) / Sorenson Spark / Sorenson H.263"), |
| 836 | 843 | .pix_fmts= ff_pixfmt_list_420, |
| 837 | 844 | }; |
| 845 | + | |
| 846 | +#if CONFIG_MPEG4_VDPAU_DECODER | |
| 847 | +AVCodec mpeg4_vdpau_decoder = { | |
| 848 | + "mpeg4_vdpau", | |
| 849 | + CODEC_TYPE_VIDEO, | |
| 850 | + CODEC_ID_MPEG4, | |
| 851 | + sizeof(MpegEncContext), | |
| 852 | + ff_h263_decode_init, | |
| 853 | + NULL, | |
| 854 | + ff_h263_decode_end, | |
| 855 | + ff_h263_decode_frame, | |
| 856 | + CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU, | |
| 857 | + .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 (VDPAU)"), | |
| 858 | + .pix_fmts= (const enum PixelFormat[]){PIX_FMT_VDPAU_MPEG4, PIX_FMT_NONE}, | |
| 859 | +}; | |
| 860 | +#endif | |
| @@ -376,6 +376,11 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = { · 375 unmodified lines | ||
| 376 | 376 | .is_hwaccel = 1, |
| 377 | 377 | .x_chroma_shift = 1, .y_chroma_shift = 1, |
| 378 | 378 | }, |
| 379 | + [PIX_FMT_VDPAU_MPEG4] = { | |
| 380 | + .name = "vdpau_mpeg4", | |
| 381 | + .is_hwaccel = 1, | |
| 382 | + .x_chroma_shift = 1, .y_chroma_shift = 1, | |
| 383 | + }, | |
| 379 | 384 | [PIX_FMT_UYYVYY411] = { |
| 380 | 385 | .name = "uyyvyy411", |
| 381 | 386 | .nb_channels = 1, |
| @@ -305,4 +305,54 @@ void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf, · 304 unmodified lines | ||
| 305 | 305 | render->bitstream_buffers_used = 0; |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | +void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf, | |
| 309 | + int buf_size) | |
| 310 | +{ | |
| 311 | + struct vdpau_render_state *render, *last, *next; | |
| 312 | + int i; | |
| 313 | + | |
| 314 | + if (!s->current_picture_ptr) return; | |
| 315 | + | |
| 316 | + render = (struct vdpau_render_state *)s->current_picture_ptr->data[0]; | |
| 317 | + assert(render); | |
| 318 | + | |
| 319 | + /* fill VdpPictureInfoMPEG4Part2 struct */ | |
| 320 | + render->info.mpeg4.vop_time_increment_resolution = s->avctx->time_base.den; | |
| 321 | + render->info.mpeg4.vop_coding_type = 0; | |
| 322 | + render->info.mpeg4.vop_fcode_forward = s->f_code; | |
| 323 | + render->info.mpeg4.vop_fcode_backward = s->b_code; | |
| 324 | + render->info.mpeg4.resync_marker_disable = !s->resync_marker; | |
| 325 | + render->info.mpeg4.interlaced = !s->progressive_sequence; | |
| 326 | + render->info.mpeg4.quant_type = s->mpeg_quant; | |
| 327 | + render->info.mpeg4.quarter_sample = s->quarter_sample; | |
| 328 | + render->info.mpeg4.short_video_header = s->avctx->codec->id == CODEC_ID_H263; | |
| 329 | + render->info.mpeg4.rounding_control = s->no_rounding; | |
| 330 | + render->info.mpeg4.alternate_vertical_scan_flag = s->alternate_scan; | |
| 331 | + render->info.mpeg4.top_field_first = s->top_field_first; | |
| 332 | + for (i = 0; i < 64; ++i) { | |
| 333 | + render->info.mpeg4.intra_quantizer_matrix[i] = s->intra_matrix[i]; | |
| 334 | + render->info.mpeg4.non_intra_quantizer_matrix[i] = s->inter_matrix[i]; | |
| 335 | + } | |
| 336 | + render->info.mpeg4.forward_reference = VDP_INVALID_HANDLE; | |
| 337 | + render->info.mpeg4.backward_reference = VDP_INVALID_HANDLE; | |
| 338 | + | |
| 339 | + switch (s->pict_type) { | |
| 340 | + case FF_B_TYPE: | |
| 341 | + next = (struct vdpau_render_state *)s->next_picture.data[0]; | |
| 342 | + assert(next); | |
| 343 | + render->info.mpeg4.backward_reference = next->surface; | |
| 344 | + render->info.mpeg4.vop_coding_type = 2; | |
| 345 | + // no break here, going to set forward prediction | |
| 346 | + case FF_P_TYPE: | |
| 347 | + last = (struct vdpau_render_state *)s->last_picture.data[0]; | |
| 348 | + assert(last); | |
| 349 | + render->info.mpeg4.forward_reference = last->surface; | |
| 350 | + } | |
| 351 | + | |
| 352 | + ff_vdpau_add_data_chunk(s, buf, buf_size); | |
| 353 | + | |
| 354 | + ff_draw_horiz_band(s, 0, s->avctx->height); | |
| 355 | + render->bitstream_buffers_used = 0; | |
| 356 | +} | |
| 357 | + | |
| 308 | 358 | /* @}*/ |
| @@ -73,6 +73,7 @@ struct vdpau_render_state { · 72 unmodified lines | ||
| 73 | 73 | VdpPictureInfoH264 h264; |
| 74 | 74 | VdpPictureInfoMPEG1Or2 mpeg; |
| 75 | 75 | VdpPictureInfoVC1 vc1; |
| 76 | + VdpPictureInfoMPEG4Part2 mpeg4; | |
| 76 | 77 | } info; |
| 77 | 78 | |
| 78 | 79 | /** Describe size/location of the compressed video data. |
| @@ -39,4 +39,7 @@ void ff_vdpau_h264_picture_complete(MpegEncContext *s); · 38 unmodified lines | ||
| 39 | 39 | void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf, |
| 40 | 40 | int buf_size); |
| 41 | 41 | |
| 42 | +void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf, | |
| 43 | + int buf_size); | |
| 44 | + | |
| 42 | 45 | #endif /* AVCODEC_VDPAU_INTERNAL_H */ |
| @@ -123,6 +123,7 @@ enum PixelFormat { · 122 unmodified lines | ||
| 123 | 123 | PIX_FMT_YUV422P16BE, ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian |
| 124 | 124 | PIX_FMT_YUV444P16LE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian |
| 125 | 125 | PIX_FMT_YUV444P16BE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian |
| 126 | + PIX_FMT_VDPAU_MPEG4, ///< MPEG4 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers | |
| 126 | 127 | PIX_FMT_NB, ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions |
| 127 | 128 | }; |
| 128 | 129 | |