FFmpeg
Loading...
Searching...
No Matches
nvdec_mjpeg.c
Go to the documentation of this file.
1/*
2 * MJPEG HW decode acceleration through NVDEC
3 *
4 * Copyright (c) 2017 Philip Langdale
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#include "avcodec.h"
24#include "internal.h"
25#include "mjpegdec.h"
26#include "nvdec.h"
27#include "decode.h"
28#include "hwaccel_internal.h"
29
31 const AVBufferRef *buffer_ref,
32 const uint8_t *buffer, uint32_t size)
33{
35
37 CUVIDPICPARAMS *pp = &ctx->pic_params;
38 FrameDecodeData *fdd;
39 NVDECFrame *cf;
40 AVFrame *cur_frame = s->picture;
41
42 int ret;
43
44 ret = ff_nvdec_start_frame(avctx, cur_frame);
45 if (ret < 0)
46 return ret;
47
48 fdd = cur_frame->private_ref;
49 cf = (NVDECFrame*)fdd->hwaccel_priv;
50
51 *pp = (CUVIDPICPARAMS) {
52 .PicWidthInMbs = (cur_frame->width + 15) / 16,
53 .FrameHeightInMbs = (cur_frame->height + 15) / 16,
54 .CurrPicIdx = cf->idx,
55
56 .intra_pic_flag = 1,
57 .ref_pic_flag = 0,
58 };
59
61}
62
63static int nvdec_mjpeg_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
64{
65 return 0;
66}
67
69 AVBufferRef *hw_frames_ctx)
70{
71 // Only need storage for the current frame
72 return ff_nvdec_frame_params(avctx, hw_frames_ctx, AV_PIX_FMT_CUDA, 1, 0);
73}
74
76 .p.name = "mjpeg_nvdec",
77 .p.type = AVMEDIA_TYPE_VIDEO,
78 .p.id = AV_CODEC_ID_MJPEG,
79 .p.pix_fmt = AV_PIX_FMT_CUDA,
80 .start_frame = nvdec_mjpeg_start_frame,
81 .end_frame = ff_nvdec_simple_end_frame,
82 .decode_slice = nvdec_mjpeg_decode_slice,
83 .frame_params = nvdec_mjpeg_frame_params,
85 .uninit = ff_nvdec_decode_uninit,
86 .priv_data_size = sizeof(NVDECContext),
87};
Libavcodec external API header.
#define s(width, name)
Definition cbs_vp9.c:198
@ AV_CODEC_ID_MJPEG
Definition codec_id.h:57
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
const struct FFHWAccel ff_mjpeg_nvdec_hwaccel
Definition nvdec_mjpeg.c:75
common internal api header.
MJPEG decoder.
int ff_nvdec_simple_end_frame(AVCodecContext *avctx)
Definition nvdec.c:1051
int ff_nvdec_simple_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
Definition nvdec.c:1061
int ff_nvdec_decode_init(AVCodecContext *avctx)
Definition nvdec.c:404
int ff_nvdec_start_frame(AVCodecContext *avctx, AVFrame *frame)
Definition nvdec.c:946
int ff_nvdec_decode_uninit(AVCodecContext *avctx)
Definition nvdec.c:297
int ff_nvdec_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx, enum AVPixelFormat hw_format, int dpb_size, int supports_444)
Definition nvdec.c:1083
static int nvdec_mjpeg_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
Definition nvdec_mjpeg.c:63
static int nvdec_mjpeg_start_frame(AVCodecContext *avctx, const AVBufferRef *buffer_ref, const uint8_t *buffer, uint32_t size)
Definition nvdec_mjpeg.c:30
static int nvdec_mjpeg_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx)
Definition nvdec_mjpeg.c:68
@ AV_PIX_FMT_CUDA
HW acceleration through CUDA.
Definition pixfmt.h:260
A reference to a data buffer.
Definition buffer.h:82
main external API structure.
Definition avcodec.h:443
struct AVCodecInternal * internal
Private context used for internal data.
Definition avcodec.h:478
void * priv_data
Definition avcodec.h:470
void * hwaccel_priv_data
hwaccel-specific private data
Definition internal.h:130
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
int width
Definition frame.h:544
int height
Definition frame.h:544
void * private_ref
RefStruct reference for internal use by a single libav* library.
Definition frame.h:810
This struct stores per-frame lavc-internal data and is attached to it via private_ref.
Definition decode.h:33
void * hwaccel_priv
Definition decode.h:54
unsigned int idx
Definition nvdec.h:55
static AVFormatContext * ctx
Definition movenc.c:49
static char buffer[20]
Definition seek.c:32
int size