This commit adds a reference to the buffer as an argument to start_frame, and adapts all existing code. This allows for asynchronous hardware accelerators to skip copying packet data by referencing it.
Unified · Split
| @@ -1389,7 +1389,8 @@ static int av1_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) · 1388 unmodified lines | ||
| 1389 | 1389 | s->cur_frame.temporal_id = header->temporal_id; |
| 1390 | 1390 | |
| 1391 | 1391 | if (avctx->hwaccel && s->cur_frame.f) { |
| 1392 | − ret = FF_HW_CALL(avctx, start_frame, unit->data, unit->data_size); | |
| 1392 | + ret = FF_HW_CALL(avctx, start_frame, s->pkt->buf, | |
| 1393 | + unit->data, unit->data_size); | |
| 1393 | 1394 | if (ret < 0) { |
| 1394 | 1395 | av_log(avctx, AV_LOG_ERROR, "HW accel start frame fail.\n"); |
| 1395 | 1396 | goto end; |
| @@ -45,7 +45,10 @@ typedef struct AV1DecodePictureContext { · 44 unmodified lines | ||
| 45 | 45 | unsigned bitstream_size; |
| 46 | 46 | } AV1DecodePictureContext; |
| 47 | 47 | |
| 48 | −static int d3d12va_av1_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) | |
| 48 | +static int d3d12va_av1_start_frame(AVCodecContext *avctx, | |
| 49 | + av_unused const AVBufferRef *buffer_ref, | |
| 50 | + av_unused const uint8_t *buffer, | |
| 51 | + av_unused uint32_t size) | |
| 49 | 52 | { |
| 50 | 53 | const AV1DecContext *h = avctx->priv_data; |
| 51 | 54 | AV1DecodePictureContext *ctx_pic = h->cur_frame.hwaccel_picture_private; |
| @@ -50,8 +50,9 @@ static void fill_slice_short(DXVA_Slice_H264_Short *slice, · 49 unmodified lines | ||
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | static int d3d12va_h264_start_frame(AVCodecContext *avctx, |
| 53 | − av_unused const uint8_t *buffer, | |
| 54 | − av_unused uint32_t size) | |
| 53 | + av_unused const AVBufferRef *buffer_ref, | |
| 54 | + av_unused const uint8_t *buffer, | |
| 55 | + av_unused uint32_t size) | |
| 55 | 56 | { |
| 56 | 57 | const H264Context *h = avctx->priv_data; |
| 57 | 58 | H264DecodePictureContext *ctx_pic = h->cur_pic_ptr->hwaccel_picture_private; |
| @@ -49,7 +49,10 @@ static void fill_slice_short(DXVA_Slice_HEVC_Short *slice, unsigned position, un · 48 unmodified lines | ||
| 49 | 49 | slice->wBadSliceChopping = 0; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | −static int d3d12va_hevc_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) | |
| 52 | +static int d3d12va_hevc_start_frame(AVCodecContext *avctx, | |
| 53 | + av_unused const AVBufferRef *buffer_ref, | |
| 54 | + av_unused const uint8_t *buffer, | |
| 55 | + av_unused uint32_t size) | |
| 53 | 56 | { |
| 54 | 57 | const HEVCContext *h = avctx->priv_data; |
| 55 | 58 | D3D12VADecodeContext *ctx = D3D12VA_DECODE_CONTEXT(avctx); |
| @@ -40,7 +40,10 @@ typedef struct D3D12DecodePictureContext { · 39 unmodified lines | ||
| 40 | 40 | unsigned bitstream_size; |
| 41 | 41 | } D3D12DecodePictureContext; |
| 42 | 42 | |
| 43 | −static int d3d12va_mpeg2_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) | |
| 43 | +static int d3d12va_mpeg2_start_frame(AVCodecContext *avctx, | |
| 44 | + av_unused const AVBufferRef *buffer_ref, | |
| 45 | + av_unused const uint8_t *buffer, | |
| 46 | + av_unused uint32_t size) | |
| 44 | 47 | { |
| 45 | 48 | const MpegEncContext *s = avctx->priv_data; |
| 46 | 49 | D3D12VADecodeContext *ctx = D3D12VA_DECODE_CONTEXT(avctx); |
| @@ -41,7 +41,10 @@ typedef struct D3D12DecodePictureContext { · 40 unmodified lines | ||
| 41 | 41 | unsigned bitstream_size; |
| 42 | 42 | } D3D12DecodePictureContext; |
| 43 | 43 | |
| 44 | −static int d3d12va_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) | |
| 44 | +static int d3d12va_vc1_start_frame(AVCodecContext *avctx, | |
| 45 | + av_unused const AVBufferRef *buffer_ref, | |
| 46 | + av_unused const uint8_t *buffer, | |
| 47 | + av_unused uint32_t size) | |
| 45 | 48 | { |
| 46 | 49 | const VC1Context *v = avctx->priv_data; |
| 47 | 50 | D3D12VADecodeContext *ctx = D3D12VA_DECODE_CONTEXT(avctx); |
| @@ -45,7 +45,10 @@ static void fill_slice_short(DXVA_Slice_VPx_Short *slice, unsigned position, uns · 44 unmodified lines | ||
| 45 | 45 | slice->wBadSliceChopping = 0; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | −static int d3d12va_vp9_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) | |
| 48 | +static int d3d12va_vp9_start_frame(AVCodecContext *avctx, | |
| 49 | + av_unused const AVBufferRef *buffer_ref, | |
| 50 | + av_unused const uint8_t *buffer, | |
| 51 | + av_unused uint32_t size) | |
| 49 | 52 | { |
| 50 | 53 | const VP9SharedContext *h = avctx->priv_data; |
| 51 | 54 | D3D12VADecodeContext *ctx = D3D12VA_DECODE_CONTEXT(avctx); |
| @@ -272,6 +272,7 @@ int ff_dxva2_av1_fill_picture_parameters(const AVCodecContext *avctx, AVDXVACont · 271 unmodified lines | ||
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | static int dxva2_av1_start_frame(AVCodecContext *avctx, |
| 275 | + av_unused const AVBufferRef *buffer_ref, | |
| 275 | 276 | av_unused const uint8_t *buffer, |
| 276 | 277 | av_unused uint32_t size) |
| 277 | 278 | { |
| @@ -444,6 +444,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, · 443 unmodified lines | ||
| 444 | 444 | |
| 445 | 445 | |
| 446 | 446 | static int dxva2_h264_start_frame(AVCodecContext *avctx, |
| 447 | + av_unused const AVBufferRef *buffer_ref, | |
| 447 | 448 | av_unused const uint8_t *buffer, |
| 448 | 449 | av_unused uint32_t size) |
| 449 | 450 | { |
| @@ -363,6 +363,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, · 362 unmodified lines | ||
| 363 | 363 | |
| 364 | 364 | |
| 365 | 365 | static int dxva2_hevc_start_frame(AVCodecContext *avctx, |
| 366 | + av_unused const AVBufferRef *buffer_ref, | |
| 366 | 367 | av_unused const uint8_t *buffer, |
| 367 | 368 | av_unused uint32_t size) |
| 368 | 369 | { |
| @@ -257,6 +257,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, · 256 unmodified lines | ||
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | static int dxva2_mpeg2_start_frame(AVCodecContext *avctx, |
| 260 | + av_unused const AVBufferRef *buffer_ref, | |
| 260 | 261 | av_unused const uint8_t *buffer, |
| 261 | 262 | av_unused uint32_t size) |
| 262 | 263 | { |
| @@ -315,6 +315,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, · 314 unmodified lines | ||
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | static int dxva2_vc1_start_frame(AVCodecContext *avctx, |
| 318 | + av_unused const AVBufferRef *buffer_ref, | |
| 318 | 319 | av_unused const uint8_t *buffer, |
| 319 | 320 | av_unused uint32_t size) |
| 320 | 321 | { |
| @@ -254,6 +254,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, · 253 unmodified lines | ||
| 254 | 254 | |
| 255 | 255 | |
| 256 | 256 | static int dxva2_vp9_start_frame(AVCodecContext *avctx, |
| 257 | + av_unused const AVBufferRef *buffer_ref, | |
| 257 | 258 | av_unused const uint8_t *buffer, |
| 258 | 259 | av_unused uint32_t size) |
| 259 | 260 | { |
| @@ -742,7 +742,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, · 741 unmodified lines | ||
| 742 | 742 | |
| 743 | 743 | /* Start */ |
| 744 | 744 | if (hwaccel) { |
| 745 | − ret = hwaccel->start_frame(avctx, avpkt->data, avpkt->size); | |
| 745 | + ret = hwaccel->start_frame(avctx, avpkt->buf, avpkt->data, avpkt->size); | |
| 746 | 746 | if (ret < 0) |
| 747 | 747 | return ret; |
| 748 | 748 | } |
| @@ -561,7 +561,7 @@ retry: · 560 unmodified lines | ||
| 561 | 561 | ff_thread_finish_setup(avctx); |
| 562 | 562 | |
| 563 | 563 | if (avctx->hwaccel) { |
| 564 | − ret = FF_HW_CALL(avctx, start_frame, | |
| 564 | + ret = FF_HW_CALL(avctx, start_frame, NULL, | |
| 565 | 565 | s->gb.buffer, s->gb.buffer_end - s->gb.buffer); |
| 566 | 566 | if (ret < 0 ) |
| 567 | 567 | return ret; |
| @@ -587,7 +587,8 @@ static void debug_green_metadata(const H264SEIGreenMetaData *gm, void *logctx) · 586 unmodified lines | ||
| 587 | 587 | } |
| 588 | 588 | } |
| 589 | 589 | |
| 590 | −static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size) | |
| 590 | +static int decode_nal_units(H264Context *h, AVBufferRef *buf_ref, | |
| 591 | + const uint8_t *buf, int buf_size) | |
| 591 | 592 | { |
| 592 | 593 | AVCodecContext *const avctx = h->avctx; |
| 593 | 594 | int nals_needed = 0; ///< number of NALs that need decoding before the next frame thread starts |
| @@ -668,7 +669,8 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size) · 74 unmodified lines | ||
| 668 | 669 | } |
| 669 | 670 | |
| 670 | 671 | if (h->avctx->hwaccel && |
| 671 | − (ret = FF_HW_CALL(h->avctx, start_frame, buf, buf_size)) < 0) | |
| 672 | + (ret = FF_HW_CALL(h->avctx, start_frame, buf_ref, | |
| 673 | + buf, buf_size)) < 0) | |
| 672 | 674 | goto end; |
| 673 | 675 | } |
| 674 | 676 | |
| @@ -1053,7 +1055,7 @@ static int h264_decode_frame(AVCodecContext *avctx, AVFrame *pict, · 378 unmodified lines | ||
| 1053 | 1055 | avctx->err_recognition, avctx); |
| 1054 | 1056 | } |
| 1055 | 1057 | |
| 1056 | − buf_index = decode_nal_units(h, buf, buf_size); | |
| 1058 | + buf_index = decode_nal_units(h, avpkt->buf, buf, buf_size); | |
| 1057 | 1059 | if (buf_index < 0) |
| 1058 | 1060 | return AVERROR_INVALIDDATA; |
| 1059 | 1061 | |
| @@ -3401,7 +3401,10 @@ static int hevc_frame_start(HEVCContext *s, HEVCLayerContext *l, · 3400 unmodified lines | ||
| 3401 | 3401 | goto fail; |
| 3402 | 3402 | |
| 3403 | 3403 | if (s->avctx->hwaccel) { |
| 3404 | − ret = FF_HW_CALL(s->avctx, start_frame, NULL, 0); | |
| 3404 | + AVCodecInternal *avci = s->avctx->internal; | |
| 3405 | + AVPacket *avpkt = avci->in_pkt; | |
| 3406 | + ret = FF_HW_CALL(s->avctx, start_frame, | |
| 3407 | + avpkt->buf, NULL, 0); | |
| 3405 | 3408 | if (ret < 0) |
| 3406 | 3409 | goto fail; |
| 3407 | 3410 | } |
| @@ -52,11 +52,13 @@ typedef struct FFHWAccel { · 51 unmodified lines | ||
| 52 | 52 | * Otherwise, this means the whole frame is available at this point. |
| 53 | 53 | * |
| 54 | 54 | * @param avctx the codec context |
| 55 | + * @param buf_ref the frame data buffer reference (optional) | |
| 55 | 56 | * @param buf the frame data buffer base |
| 56 | 57 | * @param buf_size the size of the frame in bytes |
| 57 | 58 | * @return zero if successful, a negative value otherwise |
| 58 | 59 | */ |
| 59 | − int (*start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size); | |
| 60 | + int (*start_frame)(AVCodecContext *avctx, const AVBufferRef *buf_ref, | |
| 61 | + const uint8_t *buf, uint32_t buf_size); | |
| 60 | 62 | |
| 61 | 63 | /** |
| 62 | 64 | * Callback for parameter data (SPS/PPS/VPS etc). |
| @@ -808,7 +808,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) · 807 unmodified lines | ||
| 808 | 808 | if (!s->hwaccel_picture_private) |
| 809 | 809 | return AVERROR(ENOMEM); |
| 810 | 810 | |
| 811 | − ret = hwaccel->start_frame(s->avctx, s->raw_image_buffer, | |
| 811 | + ret = hwaccel->start_frame(s->avctx, NULL, s->raw_image_buffer, | |
| 812 | 812 | s->raw_image_buffer_size); |
| 813 | 813 | if (ret < 0) |
| 814 | 814 | return ret; |
| @@ -1361,7 +1361,7 @@ static int mpeg_field_start(Mpeg1Context *s1, const uint8_t *buf, int buf_size) · 1360 unmodified lines | ||
| 1361 | 1361 | } |
| 1362 | 1362 | |
| 1363 | 1363 | if (avctx->hwaccel) { |
| 1364 | − if ((ret = FF_HW_CALL(avctx, start_frame, buf, buf_size)) < 0) | |
| 1364 | + if ((ret = FF_HW_CALL(avctx, start_frame, NULL, buf, buf_size)) < 0) | |
| 1365 | 1365 | return ret; |
| 1366 | 1366 | } else if (s->codec_tag == MKTAG('V', 'C', 'R', '2')) { |
| 1367 | 1367 | // Exchange UV |
| @@ -39,7 +39,9 @@ static int get_bit_depth_from_seq(const AV1RawSequenceHeader *seq) · 38 unmodified lines | ||
| 39 | 39 | return 8; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | −static int nvdec_av1_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) | |
| 42 | +static int nvdec_av1_start_frame(AVCodecContext *avctx, | |
| 43 | + const AVBufferRef *buffer_ref, | |
| 44 | + const uint8_t *buffer, uint32_t size) | |
| 43 | 45 | { |
| 44 | 46 | const AV1DecContext *s = avctx->priv_data; |
| 45 | 47 | const AV1RawSequenceHeader *seq = s->raw_seq; |
| @@ -47,6 +47,7 @@ static void dpb_add(const H264Context *h, CUVIDH264DPBENTRY *dst, const H264Pict · 46 unmodified lines | ||
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | static int nvdec_h264_start_frame(AVCodecContext *avctx, |
| 50 | + const AVBufferRef *buffer_ref, | |
| 50 | 51 | const uint8_t *buffer, uint32_t size) |
| 51 | 52 | { |
| 52 | 53 | const H264Context *h = avctx->priv_data; |
| @@ -70,6 +70,7 @@ static void fill_scaling_lists(CUVIDHEVCPICPARAMS *ppc, const HEVCContext *s) · 69 unmodified lines | ||
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | static int nvdec_hevc_start_frame(AVCodecContext *avctx, |
| 73 | + const AVBufferRef *buffer_ref, | |
| 73 | 74 | const uint8_t *buffer, uint32_t size) |
| 74 | 75 | { |
| 75 | 76 | const HEVCContext *s = avctx->priv_data; |
| @@ -27,7 +27,9 @@ · 26 unmodified lines | ||
| 27 | 27 | #include "decode.h" |
| 28 | 28 | #include "hwaccel_internal.h" |
| 29 | 29 | |
| 30 | −static int nvdec_mjpeg_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) | |
| 30 | +static int nvdec_mjpeg_start_frame(AVCodecContext *avctx, | |
| 31 | + const AVBufferRef *buffer_ref, | |
| 32 | + const uint8_t *buffer, uint32_t size) | |
| 31 | 33 | { |
| 32 | 34 | MJpegDecodeContext *s = avctx->priv_data; |
| 33 | 35 | |
| @@ -30,7 +30,9 @@ · 29 unmodified lines | ||
| 30 | 30 | #include "nvdec.h" |
| 31 | 31 | #include "decode.h" |
| 32 | 32 | |
| 33 | −static int nvdec_mpeg12_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) | |
| 33 | +static int nvdec_mpeg12_start_frame(AVCodecContext *avctx, | |
| 34 | + const AVBufferRef *buffer_ref, | |
| 35 | + const uint8_t *buffer, uint32_t size) | |
| 34 | 36 | { |
| 35 | 37 | MpegEncContext *s = avctx->priv_data; |
| 36 | 38 | |
| @@ -28,7 +28,9 @@ · 27 unmodified lines | ||
| 28 | 28 | #include "decode.h" |
| 29 | 29 | #include "hwaccel_internal.h" |
| 30 | 30 | |
| 31 | −static int nvdec_mpeg4_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) | |
| 31 | +static int nvdec_mpeg4_start_frame(AVCodecContext *avctx, | |
| 32 | + const AVBufferRef *buffer_ref, | |
| 33 | + const uint8_t *buffer, uint32_t size) | |
| 32 | 34 | { |
| 33 | 35 | Mpeg4DecContext *m = avctx->priv_data; |
| 34 | 36 | MpegEncContext *s = &m->m; |
| @@ -29,7 +29,9 @@ · 28 unmodified lines | ||
| 29 | 29 | #include "decode.h" |
| 30 | 30 | #include "vc1.h" |
| 31 | 31 | |
| 32 | −static int nvdec_vc1_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) | |
| 32 | +static int nvdec_vc1_start_frame(AVCodecContext *avctx, | |
| 33 | + const AVBufferRef *buffer_ref, | |
| 34 | + const uint8_t *buffer, uint32_t size) | |
| 33 | 35 | { |
| 34 | 36 | VC1Context *v = avctx->priv_data; |
| 35 | 37 | MpegEncContext *s = &v->s; |
| @@ -32,7 +32,9 @@ static unsigned char safe_get_ref_idx(VP8Frame *frame) · 31 unmodified lines | ||
| 32 | 32 | return frame ? ff_nvdec_get_ref_idx(frame->tf.f) : 255; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | −static int nvdec_vp8_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) | |
| 35 | +static int nvdec_vp8_start_frame(AVCodecContext *avctx, | |
| 36 | + const AVBufferRef *buffer_ref, | |
| 37 | + const uint8_t *buffer, uint32_t size) | |
| 36 | 38 | { |
| 37 | 39 | VP8Context *h = avctx->priv_data; |
| 38 | 40 | |
| @@ -29,7 +29,9 @@ · 28 unmodified lines | ||
| 29 | 29 | #include "internal.h" |
| 30 | 30 | #include "vp9shared.h" |
| 31 | 31 | |
| 32 | −static int nvdec_vp9_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) | |
| 32 | +static int nvdec_vp9_start_frame(AVCodecContext *avctx, | |
| 33 | + const AVBufferRef *buffer_ref, | |
| 34 | + const uint8_t *buffer, uint32_t size) | |
| 33 | 35 | { |
| 34 | 36 | VP9SharedContext *h = avctx->priv_data; |
| 35 | 37 | const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(avctx->sw_pix_fmt); |
| @@ -793,7 +793,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, · 792 unmodified lines | ||
| 793 | 793 | |
| 794 | 794 | if (HWACCEL_MAX && avctx->hwaccel) { |
| 795 | 795 | const FFHWAccel *hwaccel = ffhwaccel(avctx->hwaccel); |
| 796 | − ret = hwaccel->start_frame(avctx, NULL, 0); | |
| 796 | + ret = hwaccel->start_frame(avctx, avpkt->buf, avpkt->data, avpkt->size); | |
| 797 | 797 | if (ret < 0) |
| 798 | 798 | return ret; |
| 799 | 799 | ret = hwaccel->decode_slice(avctx, avpkt->data, avpkt->size); |
| @@ -108,6 +108,7 @@ static av_cold int vaapi_av1_decode_uninit(AVCodecContext *avctx) · 107 unmodified lines | ||
| 108 | 108 | |
| 109 | 109 | |
| 110 | 110 | static int vaapi_av1_start_frame(AVCodecContext *avctx, |
| 111 | + av_unused const AVBufferRef *buffer_ref, | |
| 111 | 112 | av_unused const uint8_t *buffer, |
| 112 | 113 | av_unused uint32_t size) |
| 113 | 114 | { |
| @@ -232,6 +232,7 @@ static void fill_vaapi_plain_pred_weight_table(const H264Context *h, · 231 unmodified lines | ||
| 232 | 232 | |
| 233 | 233 | /** Initialize and start decoding a frame with VA API. */ |
| 234 | 234 | static int vaapi_h264_start_frame(AVCodecContext *avctx, |
| 235 | + av_unused const AVBufferRef *buffer_ref, | |
| 235 | 236 | av_unused const uint8_t *buffer, |
| 236 | 237 | av_unused uint32_t size) |
| 237 | 238 | { |
| @@ -122,6 +122,7 @@ static void fill_vaapi_reference_frames(const HEVCContext *h, const HEVCLayerCon · 121 unmodified lines | ||
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | static int vaapi_hevc_start_frame(AVCodecContext *avctx, |
| 125 | + av_unused const AVBufferRef *buffer_ref, | |
| 125 | 126 | av_unused const uint8_t *buffer, |
| 126 | 127 | av_unused uint32_t size) |
| 127 | 128 | { |
| @@ -24,6 +24,7 @@ · 23 unmodified lines | ||
| 24 | 24 | #include "mjpegdec.h" |
| 25 | 25 | |
| 26 | 26 | static int vaapi_mjpeg_start_frame(AVCodecContext *avctx, |
| 27 | + av_unused const AVBufferRef *buffer_ref, | |
| 27 | 28 | av_unused const uint8_t *buffer, |
| 28 | 29 | av_unused uint32_t size) |
| 29 | 30 | { |
| @@ -39,7 +39,10 @@ static inline int mpeg2_get_is_frame_start(const MpegEncContext *s) · 38 unmodified lines | ||
| 39 | 39 | return s->first_field || s->picture_structure == PICT_FRAME; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | −static int vaapi_mpeg2_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) | |
| 42 | +static int vaapi_mpeg2_start_frame(AVCodecContext *avctx, | |
| 43 | + av_unused const AVBufferRef *buffer_ref, | |
| 44 | + av_unused const uint8_t *buffer, | |
| 45 | + av_unused uint32_t size) | |
| 43 | 46 | { |
| 44 | 47 | const MpegEncContext *s = avctx->priv_data; |
| 45 | 48 | VAAPIDecodePicture *pic = s->cur_pic.ptr->hwaccel_picture_private; |
| @@ -45,7 +45,10 @@ static int mpeg4_get_intra_dc_vlc_thr(Mpeg4DecContext *s) · 44 unmodified lines | ||
| 45 | 45 | return 0; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | −static int vaapi_mpeg4_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) | |
| 48 | +static int vaapi_mpeg4_start_frame(AVCodecContext *avctx, | |
| 49 | + av_unused const AVBufferRef *buffer_ref, | |
| 50 | + av_unused const uint8_t *buffer, | |
| 51 | + av_unused uint32_t size) | |
| 49 | 52 | { |
| 50 | 53 | Mpeg4DecContext *ctx = avctx->priv_data; |
| 51 | 54 | MpegEncContext *s = &ctx->m; |
| @@ -249,7 +249,10 @@ static inline void vc1_pack_bitplanes(uint8_t *bitplane, int n, const uint8_t *f · 248 unmodified lines | ||
| 249 | 249 | bitplane[bitplane_index] = (bitplane[bitplane_index] << 4) | v; |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | −static int vaapi_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) | |
| 252 | +static int vaapi_vc1_start_frame(AVCodecContext *avctx, | |
| 253 | + av_unused const AVBufferRef *buffer_ref, | |
| 254 | + av_unused const uint8_t *buffer, | |
| 255 | + av_unused uint32_t size) | |
| 253 | 256 | { |
| 254 | 257 | const VC1Context *v = avctx->priv_data; |
| 255 | 258 | const MpegEncContext *s = &v->s; |
| @@ -32,6 +32,7 @@ static VASurfaceID vaapi_vp8_surface_id(VP8Frame *vf) · 31 unmodified lines | ||
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | static int vaapi_vp8_start_frame(AVCodecContext *avctx, |
| 35 | + av_unused const AVBufferRef *buffer_ref, | |
| 35 | 36 | av_unused const uint8_t *buffer, |
| 36 | 37 | av_unused uint32_t size) |
| 37 | 38 | { |
| @@ -35,6 +35,7 @@ static VASurfaceID vaapi_vp9_surface_id(const VP9Frame *vf) · 34 unmodified lines | ||
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | static int vaapi_vp9_start_frame(AVCodecContext *avctx, |
| 38 | + av_unused const AVBufferRef *buffer_ref, | |
| 38 | 39 | av_unused const uint8_t *buffer, |
| 39 | 40 | av_unused uint32_t size) |
| 40 | 41 | { |
| @@ -80,6 +80,7 @@ static void fill_vaapi_reference_frames(const VVCFrameContext *h, VAPictureParam · 79 unmodified lines | ||
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | static int vaapi_vvc_start_frame(AVCodecContext *avctx, |
| 83 | + av_unused const AVBufferRef *buffer_ref, | |
| 83 | 84 | av_unused const uint8_t *buffer, |
| 84 | 85 | av_unused uint32_t size) |
| 85 | 86 | { |
| @@ -1087,7 +1087,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, AVFrame *pict, · 1086 unmodified lines | ||
| 1087 | 1087 | if (v->field_mode && buf_start_second_field) { |
| 1088 | 1088 | // decode first field |
| 1089 | 1089 | s->picture_structure = PICT_BOTTOM_FIELD - v->tff; |
| 1090 | − ret = hwaccel->start_frame(avctx, buf_start, | |
| 1090 | + ret = hwaccel->start_frame(avctx, avpkt->buf, buf_start, | |
| 1091 | 1091 | buf_start_second_field - buf_start); |
| 1092 | 1092 | if (ret < 0) |
| 1093 | 1093 | goto err; |
| @@ -1142,7 +1142,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, AVFrame *pict, · 48 unmodified lines | ||
| 1142 | 1142 | } |
| 1143 | 1143 | v->s.cur_pic.ptr->f->pict_type = v->s.pict_type; |
| 1144 | 1144 | |
| 1145 | − ret = hwaccel->start_frame(avctx, buf_start_second_field, | |
| 1145 | + ret = hwaccel->start_frame(avctx, avpkt->buf, buf_start_second_field, | |
| 1146 | 1146 | (buf + buf_size) - buf_start_second_field); |
| 1147 | 1147 | if (ret < 0) |
| 1148 | 1148 | goto err; |
| @@ -1185,7 +1185,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, AVFrame *pict, · 36 unmodified lines | ||
| 1185 | 1185 | goto err; |
| 1186 | 1186 | } else { |
| 1187 | 1187 | s->picture_structure = PICT_FRAME; |
| 1188 | − ret = hwaccel->start_frame(avctx, buf_start, | |
| 1188 | + ret = hwaccel->start_frame(avctx, avpkt->buf, buf_start, | |
| 1189 | 1189 | (buf + buf_size) - buf_start); |
| 1190 | 1190 | if (ret < 0) |
| 1191 | 1191 | goto err; |
| @@ -41,7 +41,8 @@ static int get_bit_depth_from_seq(const AV1RawSequenceHeader *seq) · 40 unmodified lines | ||
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | static int vdpau_av1_start_frame(AVCodecContext *avctx, |
| 44 | − const uint8_t *buffer, uint32_t size) | |
| 44 | + const AVBufferRef *buffer_ref, | |
| 45 | + const uint8_t *buffer, uint32_t size) | |
| 45 | 46 | { |
| 46 | 47 | AV1DecContext *s = avctx->priv_data; |
| 47 | 48 | const AV1RawSequenceHeader *seq = s->raw_seq; |
| @@ -118,6 +118,7 @@ static void vdpau_h264_set_reference_frames(AVCodecContext *avctx) · 117 unmodified lines | ||
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | static int vdpau_h264_start_frame(AVCodecContext *avctx, |
| 121 | + const AVBufferRef *buffer_ref, | |
| 121 | 122 | const uint8_t *buffer, uint32_t size) |
| 122 | 123 | { |
| 123 | 124 | H264Context * const h = avctx->priv_data; |
| @@ -32,6 +32,7 @@ · 31 unmodified lines | ||
| 32 | 32 | |
| 33 | 33 | |
| 34 | 34 | static int vdpau_hevc_start_frame(AVCodecContext *avctx, |
| 35 | + const AVBufferRef *buffer_ref, | |
| 35 | 36 | const uint8_t *buffer, uint32_t size) |
| 36 | 37 | { |
| 37 | 38 | HEVCContext *h = avctx->priv_data; |
| @@ -32,6 +32,7 @@ · 31 unmodified lines | ||
| 32 | 32 | #include "vdpau_internal.h" |
| 33 | 33 | |
| 34 | 34 | static int vdpau_mpeg_start_frame(AVCodecContext *avctx, |
| 35 | + const AVBufferRef *buffer_ref, | |
| 35 | 36 | const uint8_t *buffer, uint32_t size) |
| 36 | 37 | { |
| 37 | 38 | MpegEncContext * const s = avctx->priv_data; |
| @@ -30,6 +30,7 @@ · 29 unmodified lines | ||
| 30 | 30 | #include "vdpau_internal.h" |
| 31 | 31 | |
| 32 | 32 | static int vdpau_mpeg4_start_frame(AVCodecContext *avctx, |
| 33 | + const AVBufferRef *buffer_ref, | |
| 33 | 34 | const uint8_t *buffer, uint32_t size) |
| 34 | 35 | { |
| 35 | 36 | Mpeg4DecContext *ctx = avctx->priv_data; |
| @@ -32,6 +32,7 @@ · 31 unmodified lines | ||
| 32 | 32 | #include "vdpau_internal.h" |
| 33 | 33 | |
| 34 | 34 | static int vdpau_vc1_start_frame(AVCodecContext *avctx, |
| 35 | + const AVBufferRef *buffer_ref, | |
| 35 | 36 | const uint8_t *buffer, uint32_t size) |
| 36 | 37 | { |
| 37 | 38 | VC1Context * const v = avctx->priv_data; |
| @@ -29,7 +29,8 @@ · 28 unmodified lines | ||
| 29 | 29 | #include "vdpau_internal.h" |
| 30 | 30 | |
| 31 | 31 | static int vdpau_vp9_start_frame(AVCodecContext *avctx, |
| 32 | − const uint8_t *buffer, uint32_t size) | |
| 32 | + const AVBufferRef *buffer_ref, | |
| 33 | + const uint8_t *buffer, uint32_t size) | |
| 33 | 34 | { |
| 34 | 35 | VP9Context *s = avctx->priv_data; |
| 35 | 36 | VP9SharedContext *h = &(s->s); |
| @@ -415,6 +415,7 @@ CFDataRef ff_videotoolbox_hvcc_extradata_create(AVCodecContext *avctx) · 414 unmodified lines | ||
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | int ff_videotoolbox_h264_start_frame(AVCodecContext *avctx, |
| 418 | + const AVBufferRef *buffer_ref, | |
| 418 | 419 | const uint8_t *buffer, |
| 419 | 420 | uint32_t size) |
| 420 | 421 | { |
| @@ -1084,6 +1085,7 @@ static int videotoolbox_h264_end_frame(AVCodecContext *avctx) · 663 unmodified lines | ||
| 1084 | 1085 | } |
| 1085 | 1086 | |
| 1086 | 1087 | static int videotoolbox_hevc_start_frame(AVCodecContext *avctx, |
| 1088 | + const AVBufferRef *buffer_ref, | |
| 1087 | 1089 | const uint8_t *buffer, |
| 1088 | 1090 | uint32_t size) |
| 1089 | 1091 | { |
| @@ -1127,6 +1129,7 @@ static int videotoolbox_hevc_end_frame(AVCodecContext *avctx) · 37 unmodified lines | ||
| 1127 | 1129 | } |
| 1128 | 1130 | |
| 1129 | 1131 | static int videotoolbox_mpeg_start_frame(AVCodecContext *avctx, |
| 1132 | + const AVBufferRef *buffer_ref, | |
| 1130 | 1133 | const uint8_t *buffer, |
| 1131 | 1134 | uint32_t size) |
| 1132 | 1135 | { |
| @@ -1151,8 +1154,9 @@ static int videotoolbox_mpeg_end_frame(AVCodecContext *avctx) · 18 unmodified lines | ||
| 1151 | 1154 | } |
| 1152 | 1155 | |
| 1153 | 1156 | static int videotoolbox_prores_start_frame(AVCodecContext *avctx, |
| 1154 | − const uint8_t *buffer, | |
| 1155 | − uint32_t size) | |
| 1157 | + const AVBufferRef *buffer_ref, | |
| 1158 | + const uint8_t *buffer, | |
| 1159 | + uint32_t size) | |
| 1156 | 1160 | { |
| 1157 | 1161 | return 0; |
| 1158 | 1162 | } |
| @@ -63,6 +63,7 @@ CFDataRef ff_videotoolbox_av1c_extradata_create(AVCodecContext *avctx) · 62 unmodified lines | ||
| 63 | 63 | |
| 64 | 64 | |
| 65 | 65 | static int videotoolbox_av1_start_frame(AVCodecContext *avctx, |
| 66 | + const AVBufferRef *buffer_ref, | |
| 66 | 67 | const uint8_t *buffer, |
| 67 | 68 | uint32_t size) |
| 68 | 69 | { |
| @@ -104,6 +104,7 @@ CFDataRef ff_videotoolbox_vpcc_extradata_create(AVCodecContext *avctx) · 103 unmodified lines | ||
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | static int videotoolbox_vp9_start_frame(AVCodecContext *avctx, |
| 107 | + const AVBufferRef *buffer_ref, | |
| 107 | 108 | const uint8_t *buffer, |
| 108 | 109 | uint32_t size) |
| 109 | 110 | { |
| @@ -2729,7 +2729,7 @@ int vp78_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, · 2728 unmodified lines | ||
| 2729 | 2729 | |
| 2730 | 2730 | if (!is_vp7 && avctx->hwaccel) { |
| 2731 | 2731 | const FFHWAccel *hwaccel = ffhwaccel(avctx->hwaccel); |
| 2732 | − ret = hwaccel->start_frame(avctx, avpkt->data, avpkt->size); | |
| 2732 | + ret = hwaccel->start_frame(avctx, avpkt->buf, avpkt->data, avpkt->size); | |
| 2733 | 2733 | if (ret < 0) |
| 2734 | 2734 | goto err; |
| 2735 | 2735 | |
| @@ -1618,7 +1618,7 @@ static int vp9_decode_frame(AVCodecContext *avctx, AVFrame *frame, · 1617 unmodified lines | ||
| 1618 | 1618 | |
| 1619 | 1619 | if (avctx->hwaccel) { |
| 1620 | 1620 | const FFHWAccel *hwaccel = ffhwaccel(avctx->hwaccel); |
| 1621 | − ret = hwaccel->start_frame(avctx, NULL, 0); | |
| 1621 | + ret = hwaccel->start_frame(avctx, pkt->buf, pkt->data, pkt->size); | |
| 1622 | 1622 | if (ret < 0) |
| 1623 | 1623 | return ret; |
| 1624 | 1624 | ret = hwaccel->decode_slice(avctx, pkt->data, pkt->size); |
| @@ -61,6 +61,7 @@ int ff_videotoolbox_buffer_append(VTContext *vtctx, · 60 unmodified lines | ||
| 61 | 61 | uint32_t size); |
| 62 | 62 | int ff_videotoolbox_uninit(AVCodecContext *avctx); |
| 63 | 63 | int ff_videotoolbox_h264_start_frame(AVCodecContext *avctx, |
| 64 | + const AVBufferRef *buffer_ref, | |
| 64 | 65 | const uint8_t *buffer, |
| 65 | 66 | uint32_t size); |
| 66 | 67 | int ff_videotoolbox_h264_decode_slice(AVCodecContext *avctx, |
| @@ -245,6 +245,7 @@ static int vk_av1_create_params(AVCodecContext *avctx, AVBufferRef **buf, · 244 unmodified lines | ||
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | static int vk_av1_start_frame(AVCodecContext *avctx, |
| 248 | + av_unused const AVBufferRef *buffer_ref, | |
| 248 | 249 | av_unused const uint8_t *buffer, |
| 249 | 250 | av_unused uint32_t size) |
| 250 | 251 | { |
| @@ -359,6 +359,7 @@ static int vk_h264_create_params(AVCodecContext *avctx, AVBufferRef **buf) · 358 unmodified lines | ||
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | static int vk_h264_start_frame(AVCodecContext *avctx, |
| 362 | + av_unused const AVBufferRef *buffer_ref, | |
| 362 | 363 | av_unused const uint8_t *buffer, |
| 363 | 364 | av_unused uint32_t size) |
| 364 | 365 | { |
| @@ -709,6 +709,7 @@ static int vk_hevc_create_params(AVCodecContext *avctx, AVBufferRef **buf) · 708 unmodified lines | ||
| 709 | 709 | } |
| 710 | 710 | |
| 711 | 711 | static int vk_hevc_start_frame(AVCodecContext *avctx, |
| 712 | + av_unused const AVBufferRef *buffer_ref, | |
| 712 | 713 | av_unused const uint8_t *buffer, |
| 713 | 714 | av_unused uint32_t size) |
| 714 | 715 | { |
| @@ -831,7 +831,8 @@ static int frame_setup(VVCFrameContext *fc, VVCContext *s) · 830 unmodified lines | ||
| 831 | 831 | return 0; |
| 832 | 832 | } |
| 833 | 833 | |
| 834 | −static int decode_slice(VVCContext *s, VVCFrameContext *fc, const H2645NAL *nal, const CodedBitstreamUnit *unit) | |
| 834 | +static int decode_slice(VVCContext *s, VVCFrameContext *fc, AVBufferRef *buf_ref, | |
| 835 | + const H2645NAL *nal, const CodedBitstreamUnit *unit) | |
| 835 | 836 | { |
| 836 | 837 | int ret; |
| 837 | 838 | SliceContext *sc; |
| @@ -860,7 +861,7 @@ static int decode_slice(VVCContext *s, VVCFrameContext *fc, const H2645NAL *nal, · 22 unmodified lines | ||
| 860 | 861 | |
| 861 | 862 | if (s->avctx->hwaccel) { |
| 862 | 863 | if (is_first_slice) { |
| 863 | − ret = FF_HW_CALL(s->avctx, start_frame, NULL, 0); | |
| 864 | + ret = FF_HW_CALL(s->avctx, start_frame, buf_ref, NULL, 0); | |
| 864 | 865 | if (ret < 0) |
| 865 | 866 | return ret; |
| 866 | 867 | } |
| @@ -876,7 +877,8 @@ static int decode_slice(VVCContext *s, VVCFrameContext *fc, const H2645NAL *nal, · 9 unmodified lines | ||
| 876 | 877 | return 0; |
| 877 | 878 | } |
| 878 | 879 | |
| 879 | −static int decode_nal_unit(VVCContext *s, VVCFrameContext *fc, const H2645NAL *nal, const CodedBitstreamUnit *unit) | |
| 880 | +static int decode_nal_unit(VVCContext *s, VVCFrameContext *fc, AVBufferRef *buf_ref, | |
| 881 | + const H2645NAL *nal, const CodedBitstreamUnit *unit) | |
| 880 | 882 | { |
| 881 | 883 | int ret; |
| 882 | 884 | |
| @@ -902,7 +904,7 @@ static int decode_nal_unit(VVCContext *s, VVCFrameContext *fc, const H2645NAL *n · 19 unmodified lines | ||
| 902 | 904 | case VVC_IDR_N_LP: |
| 903 | 905 | case VVC_CRA_NUT: |
| 904 | 906 | case VVC_GDR_NUT: |
| 905 | − ret = decode_slice(s, fc, nal, unit); | |
| 907 | + ret = decode_slice(s, fc, buf_ref, nal, unit); | |
| 906 | 908 | if (ret < 0) |
| 907 | 909 | return ret; |
| 908 | 910 | break; |
| @@ -940,7 +942,7 @@ static int decode_nal_units(VVCContext *s, VVCFrameContext *fc, AVPacket *avpkt) · 31 unmodified lines | ||
| 940 | 942 | if (unit->type == VVC_EOB_NUT || unit->type == VVC_EOS_NUT) { |
| 941 | 943 | s->last_eos = 1; |
| 942 | 944 | } else { |
| 943 | − ret = decode_nal_unit(s, fc, nal, unit); | |
| 945 | + ret = decode_nal_unit(s, fc, avpkt->buf, nal, unit); | |
| 944 | 946 | if (ret < 0) { |
| 945 | 947 | av_log(s->avctx, AV_LOG_WARNING, |
| 946 | 948 | "Error parsing NAL unit #%d.\n", i); |