History

Add VDPAU hardware accelerated decoding for MPEG-4 ASP which can be used by video players.

Original patch by NVIDIA corporation. Originally committed as revision 20502 to svn://svn.ffmpeg.org/ffmpeg/trunk

NVIDIA Corporation committed 17 years ago

Commit 70e0c871 parent 00962ab8 files · +86 −0Browse files

Unified · Split

8 files
  1. configure +2 −0
  2. libavcodec/allcodecs.c +1 −0
  3. libavcodec/h263dec.c +23 −0
  4. libavcodec/imgconvert.c +5 −0
  5. libavcodec/vdpau.c +50 −0
  6. libavcodec/vdpau.h +1 −0
  7. libavcodec/vdpau_internal.h +3 −0
  8. libavutil/pixfmt.h +1 −0
configure+2−0
@@ -1131,6 +1131,8 @@ mpeg2_vaapi_hwaccel_deps="va_va_h" · 1130 unmodified lines
1131mpeg2_vaapi_hwaccel_select="vaapi mpeg2video_decoder"1131mpeg2_vaapi_hwaccel_select="vaapi mpeg2video_decoder"
1132mpeg4_vaapi_hwaccel_deps="va_va_h"1132mpeg4_vaapi_hwaccel_deps="va_va_h"
1133mpeg4_vaapi_hwaccel_select="vaapi mpeg4_decoder"1133mpeg4_vaapi_hwaccel_select="vaapi mpeg4_decoder"
1134mpeg4_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
1135mpeg4_vdpau_decoder_select="vdpau mpeg4_decoder"
1134mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"1136mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
1135mpeg_xvmc_decoder_select="mpegvideo_decoder"1137mpeg_xvmc_decoder_select="mpegvideo_decoder"
1136msmpeg4v1_encoder_select="h263_encoder"1138msmpeg4v1_encoder_select="h263_encoder"
libavcodec/allcodecs.c+1−0
@@ -123,6 +123,7 @@ void avcodec_register_all(void) · 122 unmodified lines
123 REGISTER_ENCDEC (MPEG1VIDEO, mpeg1video);123 REGISTER_ENCDEC (MPEG1VIDEO, mpeg1video);
124 REGISTER_ENCDEC (MPEG2VIDEO, mpeg2video);124 REGISTER_ENCDEC (MPEG2VIDEO, mpeg2video);
125 REGISTER_ENCDEC (MPEG4, mpeg4);125 REGISTER_ENCDEC (MPEG4, mpeg4);
126 REGISTER_DECODER (MPEG4_VDPAU, mpeg4_vdpau);
126 REGISTER_DECODER (MPEGVIDEO, mpegvideo);127 REGISTER_DECODER (MPEGVIDEO, mpegvideo);
127 REGISTER_DECODER (MPEG_VDPAU, mpeg_vdpau);128 REGISTER_DECODER (MPEG_VDPAU, mpeg_vdpau);
128 REGISTER_DECODER (MPEG1_VDPAU, mpeg1_vdpau);129 REGISTER_DECODER (MPEG1_VDPAU, mpeg1_vdpau);
libavcodec/h263dec.c+23−0
@@ -32,6 +32,7 @@ · 31 unmodified lines
32#include "h263_parser.h"32#include "h263_parser.h"
33#include "mpeg4video_parser.h"33#include "mpeg4video_parser.h"
34#include "msmpeg4.h"34#include "msmpeg4.h"
35#include "vdpau_internal.h"
35 36
36//#define DEBUG37//#define DEBUG
37//#define PRINT_FRAME_TIME38//#define PRINT_FRAME_TIME
@@ -621,6 +622,11 @@ retry: · 583 unmodified lines
621 if(MPV_frame_start(s, avctx) < 0)622 if(MPV_frame_start(s, avctx) < 0)
622 return -1;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 if (avctx->hwaccel) {630 if (avctx->hwaccel) {
625 if (avctx->hwaccel->start_frame(avctx, buf, buf_size) < 0)631 if (avctx->hwaccel->start_frame(avctx, buf, buf_size) < 0)
626 return -1;632 return -1;
@@ -695,6 +701,7 @@ retry: · 68 unmodified lines
695intrax8_decoded:701intrax8_decoded:
696 ff_er_frame_end(s);702 ff_er_frame_end(s);
697 703
704frame_end:
698 if (avctx->hwaccel) {705 if (avctx->hwaccel) {
699 if (avctx->hwaccel->end_frame(avctx) < 0)706 if (avctx->hwaccel->end_frame(avctx) < 0)
700 return -1;707 return -1;
@@ -835,3 +842,19 @@ AVCodec flv_decoder = { · 134 unmodified lines
835 .long_name= NULL_IF_CONFIG_SMALL("Flash Video (FLV) / Sorenson Spark / Sorenson H.263"),842 .long_name= NULL_IF_CONFIG_SMALL("Flash Video (FLV) / Sorenson Spark / Sorenson H.263"),
836 .pix_fmts= ff_pixfmt_list_420,843 .pix_fmts= ff_pixfmt_list_420,
837};844};
845
846#if CONFIG_MPEG4_VDPAU_DECODER
847AVCodec 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
libavcodec/imgconvert.c+5−0
@@ -376,6 +376,11 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = { · 375 unmodified lines
376 .is_hwaccel = 1,376 .is_hwaccel = 1,
377 .x_chroma_shift = 1, .y_chroma_shift = 1,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 [PIX_FMT_UYYVYY411] = {384 [PIX_FMT_UYYVYY411] = {
380 .name = "uyyvyy411",385 .name = "uyyvyy411",
381 .nb_channels = 1,386 .nb_channels = 1,
libavcodec/vdpau.c+50−0
@@ -305,4 +305,54 @@ void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf, · 304 unmodified lines
305 render->bitstream_buffers_used = 0;305 render->bitstream_buffers_used = 0;
306}306}
307 307
308void 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/* @}*/
libavcodec/vdpau.h+1−0
@@ -73,6 +73,7 @@ struct vdpau_render_state { · 72 unmodified lines
73 VdpPictureInfoH264 h264;73 VdpPictureInfoH264 h264;
74 VdpPictureInfoMPEG1Or2 mpeg;74 VdpPictureInfoMPEG1Or2 mpeg;
75 VdpPictureInfoVC1 vc1;75 VdpPictureInfoVC1 vc1;
76 VdpPictureInfoMPEG4Part2 mpeg4;
76 } info;77 } info;
77 78
78 /** Describe size/location of the compressed video data.79 /** Describe size/location of the compressed video data.
libavcodec/vdpau_internal.h+3−0
@@ -39,4 +39,7 @@ void ff_vdpau_h264_picture_complete(MpegEncContext *s); · 38 unmodified lines
39void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf,39void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf,
40 int buf_size);40 int buf_size);
41 41
42void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf,
43 int buf_size);
44
42#endif /* AVCODEC_VDPAU_INTERNAL_H */45#endif /* AVCODEC_VDPAU_INTERNAL_H */
libavutil/pixfmt.h+1−0
@@ -123,6 +123,7 @@ enum PixelFormat { · 122 unmodified lines
123 PIX_FMT_YUV422P16BE, ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian123 PIX_FMT_YUV422P16BE, ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
124 PIX_FMT_YUV444P16LE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian124 PIX_FMT_YUV444P16LE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
125 PIX_FMT_YUV444P16BE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian125 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 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 versions127 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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t