FFmpeg
Data Structures | Macros | Functions | Variables
vaapi_encode_mjpeg.c File Reference
#include <va/va.h>
#include <va/va_enc_jpeg.h>
#include "libavutil/avassert.h"
#include "libavutil/common.h"
#include "libavutil/internal.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avcodec.h"
#include "bytestream.h"
#include "cbs.h"
#include "cbs_jpeg.h"
#include "codec_internal.h"
#include "jpegtables.h"
#include "mjpeg.h"
#include "put_bits.h"
#include "vaapi_encode.h"

Go to the source code of this file.

Data Structures

struct  VAAPIEncodeMJPEGContext
 

Macros

#define OFFSET(x)   offsetof(VAAPIEncodeMJPEGContext, x)
 
#define FLAGS   (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
 

Functions

static int vaapi_encode_mjpeg_write_image_header (AVCodecContext *avctx, VAAPIEncodePicture *pic, VAAPIEncodeSlice *slice, char *data, size_t *data_len)
 
static int vaapi_encode_mjpeg_write_extra_buffer (AVCodecContext *avctx, FFHWBaseEncodePicture *base, int index, int *type, char *data, size_t *data_len)
 
static int vaapi_encode_mjpeg_init_picture_params (AVCodecContext *avctx, FFHWBaseEncodePicture *pic)
 
static int vaapi_encode_mjpeg_init_slice_params (AVCodecContext *avctx, FFHWBaseEncodePicture *base, VAAPIEncodeSlice *slice)
 
static av_cold int vaapi_encode_mjpeg_get_encoder_caps (AVCodecContext *avctx)
 
static av_cold int vaapi_encode_mjpeg_configure (AVCodecContext *avctx)
 
static av_cold int vaapi_encode_mjpeg_init (AVCodecContext *avctx)
 
static av_cold int vaapi_encode_mjpeg_close (AVCodecContext *avctx)
 

Variables

static const unsigned char vaapi_encode_mjpeg_quant_luminance [64]
 
static const unsigned char vaapi_encode_mjpeg_quant_chrominance [64]
 
static const VAAPIEncodeProfile vaapi_encode_mjpeg_profiles []
 
static const VAAPIEncodeType vaapi_encode_type_mjpeg
 
static const AVOption vaapi_encode_mjpeg_options []
 
static const FFCodecDefault vaapi_encode_mjpeg_defaults []
 
static const AVClass vaapi_encode_mjpeg_class
 
const FFCodec ff_mjpeg_vaapi_encoder
 

Macro Definition Documentation

◆ OFFSET

#define OFFSET (   x)    offsetof(VAAPIEncodeMJPEGContext, x)

Definition at line 542 of file vaapi_encode_mjpeg.c.

◆ FLAGS

Definition at line 543 of file vaapi_encode_mjpeg.c.

Function Documentation

◆ vaapi_encode_mjpeg_write_image_header()

static int vaapi_encode_mjpeg_write_image_header ( AVCodecContext avctx,
VAAPIEncodePicture pic,
VAAPIEncodeSlice slice,
char *  data,
size_t *  data_len 
)
static

Definition at line 83 of file vaapi_encode_mjpeg.c.

◆ vaapi_encode_mjpeg_write_extra_buffer()

static int vaapi_encode_mjpeg_write_extra_buffer ( AVCodecContext avctx,
FFHWBaseEncodePicture base,
int  index,
int *  type,
char *  data,
size_t *  data_len 
)
static

Definition at line 149 of file vaapi_encode_mjpeg.c.

◆ vaapi_encode_mjpeg_init_picture_params()

static int vaapi_encode_mjpeg_init_picture_params ( AVCodecContext avctx,
FFHWBaseEncodePicture pic 
)
static

Definition at line 222 of file vaapi_encode_mjpeg.c.

◆ vaapi_encode_mjpeg_init_slice_params()

static int vaapi_encode_mjpeg_init_slice_params ( AVCodecContext avctx,
FFHWBaseEncodePicture base,
VAAPIEncodeSlice slice 
)
static

Definition at line 416 of file vaapi_encode_mjpeg.c.

◆ vaapi_encode_mjpeg_get_encoder_caps()

static av_cold int vaapi_encode_mjpeg_get_encoder_caps ( AVCodecContext avctx)
static

Definition at line 439 of file vaapi_encode_mjpeg.c.

◆ vaapi_encode_mjpeg_configure()

static av_cold int vaapi_encode_mjpeg_configure ( AVCodecContext avctx)
static

Definition at line 453 of file vaapi_encode_mjpeg.c.

◆ vaapi_encode_mjpeg_init()

static av_cold int vaapi_encode_mjpeg_init ( AVCodecContext avctx)
static

Definition at line 519 of file vaapi_encode_mjpeg.c.

◆ vaapi_encode_mjpeg_close()

static av_cold int vaapi_encode_mjpeg_close ( AVCodecContext avctx)
static

Definition at line 532 of file vaapi_encode_mjpeg.c.

Variable Documentation

◆ vaapi_encode_mjpeg_quant_luminance

const unsigned char vaapi_encode_mjpeg_quant_luminance[64]
static
Initial value:
= {
16, 11, 12, 14, 12, 10, 16, 14,
13, 14, 18, 17, 16, 19, 24, 40,
26, 24, 22, 22, 24, 49, 35, 37,
29, 40, 58, 51, 61, 60, 57, 51,
56, 55, 64, 72, 92, 78, 64, 68,
87, 69, 55, 56, 80, 109, 81, 87,
95, 98, 103, 104, 103, 62, 77, 113,
121, 112, 100, 120, 92, 101, 103, 99,
}

Definition at line 40 of file vaapi_encode_mjpeg.c.

Referenced by vaapi_encode_mjpeg_init_picture_params().

◆ vaapi_encode_mjpeg_quant_chrominance

const unsigned char vaapi_encode_mjpeg_quant_chrominance[64]
static
Initial value:
= {
17, 18, 18, 24, 21, 24, 47, 26,
26, 47, 99, 66, 56, 66, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
}

Definition at line 50 of file vaapi_encode_mjpeg.c.

Referenced by vaapi_encode_mjpeg_init_picture_params().

◆ vaapi_encode_mjpeg_profiles

const VAAPIEncodeProfile vaapi_encode_mjpeg_profiles[]
static
Initial value:
= {
8, 1, 0, 0, VAProfileJPEGBaseline },
8, 3, 1, 1, VAProfileJPEGBaseline },
8, 3, 1, 0, VAProfileJPEGBaseline },
8, 3, 0, 0, VAProfileJPEGBaseline },
}

Definition at line 484 of file vaapi_encode_mjpeg.c.

◆ vaapi_encode_type_mjpeg

const VAAPIEncodeType vaapi_encode_type_mjpeg
static
Initial value:
= {
.default_quality = 80,
.picture_params_size = sizeof(VAEncPictureParameterBufferJPEG),
.init_picture_params = &vaapi_encode_mjpeg_init_picture_params,
.slice_params_size = sizeof(VAEncSliceParameterBufferJPEG),
.init_slice_params = &vaapi_encode_mjpeg_init_slice_params,
.slice_header_type = VAEncPackedHeaderRawData,
.write_slice_header = &vaapi_encode_mjpeg_write_image_header,
.write_extra_buffer = &vaapi_encode_mjpeg_write_extra_buffer,
}

Definition at line 496 of file vaapi_encode_mjpeg.c.

Referenced by vaapi_encode_mjpeg_init().

◆ vaapi_encode_mjpeg_options

const AVOption vaapi_encode_mjpeg_options[]
static
Initial value:
= {
{ "jfif", "Include JFIF header",
{ .i64 = 0 }, 0, 1, FLAGS },
{ "huffman", "Include huffman tables",
{ .i64 = 1 }, 0, 1, FLAGS },
{ NULL },
}

Definition at line 544 of file vaapi_encode_mjpeg.c.

◆ vaapi_encode_mjpeg_defaults

const FFCodecDefault vaapi_encode_mjpeg_defaults[]
static
Initial value:
= {
{ "b", "0" },
{ NULL },
}

Definition at line 558 of file vaapi_encode_mjpeg.c.

◆ vaapi_encode_mjpeg_class

const AVClass vaapi_encode_mjpeg_class
static
Initial value:
= {
.class_name = "mjpeg_vaapi",
.item_name = av_default_item_name,
}

Definition at line 563 of file vaapi_encode_mjpeg.c.

◆ ff_mjpeg_vaapi_encoder

const FFCodec ff_mjpeg_vaapi_encoder
Initial value:
= {
.p.name = "mjpeg_vaapi",
CODEC_LONG_NAME("MJPEG (VAAPI)"),
.p.type = AVMEDIA_TYPE_VIDEO,
.priv_data_size = sizeof(VAAPIEncodeMJPEGContext),
.p.priv_class = &vaapi_encode_mjpeg_class,
.p.pix_fmts = (const enum AVPixelFormat[]) {
},
.color_ranges = AVCOL_RANGE_MPEG,
.p.wrapper_name = "vaapi",
}

Definition at line 570 of file vaapi_encode_mjpeg.c.

AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: codec_internal.h:43
AV_CODEC_CAP_HARDWARE
#define AV_CODEC_CAP_HARDWARE
Codec is backed by a hardware implementation.
Definition: codec.h:145
vaapi_encode_mjpeg_init_picture_params
static int vaapi_encode_mjpeg_init_picture_params(AVCodecContext *avctx, FFHWBaseEncodePicture *pic)
Definition: vaapi_encode_mjpeg.c:222
vaapi_encode_mjpeg_options
static const AVOption vaapi_encode_mjpeg_options[]
Definition: vaapi_encode_mjpeg.c:544
vaapi_encode_mjpeg_defaults
static const FFCodecDefault vaapi_encode_mjpeg_defaults[]
Definition: vaapi_encode_mjpeg.c:558
FF_CODEC_CAP_NOT_INIT_THREADSAFE
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
Definition: codec_internal.h:35
vaapi_encode_mjpeg_get_encoder_caps
static av_cold int vaapi_encode_mjpeg_get_encoder_caps(AVCodecContext *avctx)
Definition: vaapi_encode_mjpeg.c:439
OFFSET
#define OFFSET(x)
Definition: vaapi_encode_mjpeg.c:542
vaapi_encode_mjpeg_close
static av_cold int vaapi_encode_mjpeg_close(AVCodecContext *avctx)
Definition: vaapi_encode_mjpeg.c:532
AV_PROFILE_UNKNOWN
#define AV_PROFILE_UNKNOWN
Definition: defs.h:65
AV_PROFILE_MJPEG_HUFFMAN_BASELINE_DCT
#define AV_PROFILE_MJPEG_HUFFMAN_BASELINE_DCT
Definition: defs.h:173
vaapi_encode_mjpeg_write_extra_buffer
static int vaapi_encode_mjpeg_write_extra_buffer(AVCodecContext *avctx, FFHWBaseEncodePicture *base, int index, int *type, char *data, size_t *data_len)
Definition: vaapi_encode_mjpeg.c:149
AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
Definition: codec.h:159
ff_vaapi_encode_receive_packet
int ff_vaapi_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
Definition: vaapi_encode.c:2086
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:296
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
VAAPIEncodeMJPEGContext
Definition: vaapi_encode_mjpeg.c:61
FF_CODEC_RECEIVE_PACKET_CB
#define FF_CODEC_RECEIVE_PACKET_CB(func)
Definition: codec_internal.h:326
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
vaapi_encode_mjpeg_write_image_header
static int vaapi_encode_mjpeg_write_image_header(AVCodecContext *avctx, VAAPIEncodePicture *pic, VAAPIEncodeSlice *slice, char *data, size_t *data_len)
Definition: vaapi_encode_mjpeg.c:83
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
vaapi_encode_mjpeg_class
static const AVClass vaapi_encode_mjpeg_class
Definition: vaapi_encode_mjpeg.c:563
vaapi_encode_mjpeg_profiles
static const VAAPIEncodeProfile vaapi_encode_mjpeg_profiles[]
Definition: vaapi_encode_mjpeg.c:484
VAAPI_ENCODE_COMMON_OPTIONS
#define VAAPI_ENCODE_COMMON_OPTIONS
Definition: vaapi_encode.h:350
AV_PIX_FMT_VAAPI
@ AV_PIX_FMT_VAAPI
Hardware acceleration through VA-API, data[3] contains a VASurfaceID.
Definition: pixfmt.h:126
AV_CODEC_ID_MJPEG
@ AV_CODEC_ID_MJPEG
Definition: codec_id.h:59
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:700
ff_vaapi_encode_hw_configs
const AVCodecHWConfigInternal *const ff_vaapi_encode_hw_configs[]
Definition: vaapi_encode.c:36
FF_HW_FLAG_INTRA_ONLY
@ FF_HW_FLAG_INTRA_ONLY
Definition: hw_base_encode.h:51
vaapi_encode_mjpeg_init_slice_params
static int vaapi_encode_mjpeg_init_slice_params(AVCodecContext *avctx, FFHWBaseEncodePicture *base, VAAPIEncodeSlice *slice)
Definition: vaapi_encode_mjpeg.c:416
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
FF_HW_FLAG_CONSTANT_QUALITY_ONLY
@ FF_HW_FLAG_CONSTANT_QUALITY_ONLY
Definition: hw_base_encode.h:49
FLAGS
#define FLAGS
Definition: vaapi_encode_mjpeg.c:543
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327
vaapi_encode_mjpeg_configure
static av_cold int vaapi_encode_mjpeg_configure(AVCodecContext *avctx)
Definition: vaapi_encode_mjpeg.c:453
HW_BASE_ENCODE_COMMON_OPTIONS
#define HW_BASE_ENCODE_COMMON_OPTIONS
Definition: hw_base_encode.h:239
vaapi_encode_mjpeg_init
static av_cold int vaapi_encode_mjpeg_init(AVCodecContext *avctx)
Definition: vaapi_encode_mjpeg.c:519