20 #include <va/va_enc_jpeg.h> 
   38     16,  11,  12,  14,  12,  10,  16,  14,
 
   39     13,  14,  18,  17,  16,  19,  24,  40,
 
   40     26,  24,  22,  22,  24,  49,  35,  37,
 
   41     29,  40,  58,  51,  61,  60,  57,  51,
 
   42     56,  55,  64,  72,  92,  78,  64,  68,
 
   43     87,  69,  55,  56,  80, 109,  81,  87,
 
   44     95,  98, 103, 104, 103,  62,  77, 113,
 
   45    121, 112, 100, 120,  92, 101, 103,  99,
 
   48     17,  18,  18,  24,  21,  24,  47,  26,
 
   49     26,  47,  99,  66,  56,  66,  99,  99,
 
   50     99,  99,  99,  99,  99,  99,  99,  99,
 
   51     99,  99,  99,  99,  99,  99,  99,  99,
 
   52     99,  99,  99,  99,  99,  99,  99,  99,
 
   53     99,  99,  99,  99,  99,  99,  99,  99,
 
   54     99,  99,  99,  99,  99,  99,  99,  99,
 
   55     99,  99,  99,  99,  99,  99,  99,  99,
 
   68                                                     unsigned char *dst_values,
 
   69                                                     const unsigned char *src_lengths,
 
   70                                                     const unsigned char *src_values)
 
   77     for (i = 0; i < 16; i++)
 
   78         mt += (dst_lengths[i] = src_lengths[i]);
 
   80     for (i = 0; i < mt; i++)
 
   81         dst_values[i] = src_values[i];
 
   92     quant->load_lum_quantiser_matrix = 1;
 
   93     quant->load_chroma_quantiser_matrix = 1;
 
   95     for (i = 0; i < 64; i++) {
 
   96         quant->lum_quantiser_matrix[i] =
 
   98         quant->chroma_quantiser_matrix[i] =
 
  102     huff->load_huffman_table[0] = 1;
 
  104                                     huff->huffman_table[0].dc_values,
 
  108                                     huff->huffman_table[0].ac_values,
 
  111     memset(huff->huffman_table[0].pad, 0, 
sizeof(huff->huffman_table[0].pad));
 
  113     huff->load_huffman_table[1] = 1;
 
  115                                     huff->huffman_table[1].dc_values,
 
  119                                     huff->huffman_table[1].ac_values,
 
  122     memset(huff->huffman_table[1].pad, 0, 
sizeof(huff->huffman_table[1].pad));
 
  134                                                  char *
data, 
size_t *data_len)
 
  141     int t, i, quant_scale;
 
  150         quant_scale = 5000 / priv->
quality;
 
  152         quant_scale = 200 - 2 * priv->
quality;
 
  154     for (t = 0; t < 2; t++) {
 
  163         for (i = 0; i < 64; i++) {
 
  166             q = (q * quant_scale) / 100;
 
  168             if (q > 255) q = 255;
 
  175     put_bits(&pbc, 16, 8 + 3 * vpic->num_components); 
 
  176     put_bits(&pbc, 8,  vpic->sample_bit_depth); 
 
  177     put_bits(&pbc, 16, vpic->picture_height);   
 
  178     put_bits(&pbc, 16, vpic->picture_width);    
 
  179     put_bits(&pbc, 8,  vpic->num_components);   
 
  181     for (i = 0; i < vpic->num_components; i++) {
 
  182         put_bits(&pbc, 8, vpic->component_id[i]); 
 
  185         put_bits(&pbc, 8, vpic->quantiser_table_selector[i]); 
 
  188     for (t = 0; t < 4; t++) {
 
  190         unsigned char *lengths, *values;
 
  203         for (i = 0; i < 16; i++)
 
  210         for (i = 0; i < 16; i++)
 
  212         for (i = 0; i < mt; i++)
 
  218     av_assert0(vpic->num_components == vslice->num_components);
 
  220     put_bits(&pbc, 16, 6 + 2 * vslice->num_components); 
 
  221     put_bits(&pbc, 8,  vslice->num_components); 
 
  223     for (i = 0; i < vslice->num_components; i++) {
 
  224         put_bits(&pbc, 8, vslice->components[i].component_selector); 
 
  225         put_bits(&pbc, 4, vslice->components[i].dc_table_selector);  
 
  226         put_bits(&pbc, 4, vslice->components[i].ac_table_selector);  
 
  243                                                  char *
data, 
size_t *data_len)
 
  252         *type = VAQMatrixBufferType;
 
  256     } 
else if (index == 1) {
 
  260         *type = VAHuffmanTableBufferType;
 
  280     vpic->picture_width  = avctx->
width;
 
  281     vpic->picture_height = avctx->
height;
 
  283     vpic->pic_flags.bits.profile      = 0;
 
  284     vpic->pic_flags.bits.progressive  = 0;
 
  285     vpic->pic_flags.bits.huffman      = 1;
 
  286     vpic->pic_flags.bits.interleaved  = 0;
 
  287     vpic->pic_flags.bits.differential = 0;
 
  289     vpic->sample_bit_depth = 8;
 
  292     vpic->num_components = 3;
 
  294     vpic->component_id[0] = 1;
 
  295     vpic->component_id[1] = 2;
 
  296     vpic->component_id[2] = 3;
 
  305     vpic->quantiser_table_selector[0] = 0;
 
  306     vpic->quantiser_table_selector[1] = 1;
 
  307     vpic->quantiser_table_selector[2] = 1;
 
  324     vslice->restart_interval = 0;
 
  326     vslice->num_components = vpic->num_components;
 
  327     for (i = 0; i < vslice->num_components; i++) {
 
  328         vslice->components[i].component_selector = i + 1;
 
  329         vslice->components[i].dc_table_selector = (i > 0);
 
  330         vslice->components[i].ac_table_selector = (i > 0);
 
  344                "(must be 1-100).\n", priv->
quality);
 
  369     .picture_params_size   = 
sizeof(VAEncPictureParameterBufferJPEG),
 
  372     .slice_params_size     = 
sizeof(VAEncSliceParameterBufferJPEG),
 
  375     .slice_header_type     = VAEncPackedHeaderRawData,
 
  396         VA_ENC_PACKED_HEADER_RAW_DATA;
 
  405     { 
"global_quality", 
"80" },
 
  416     .
name           = 
"mjpeg_vaapi",
 
  424     .priv_class     = &vaapi_encode_mjpeg_class,
 
  425     .
defaults       = vaapi_encode_mjpeg_defaults,
 
VAEntrypoint va_entrypoint
ptrdiff_t const GLvoid * data
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit 
#define LIBAVUTIL_VERSION_INT
av_cold int ff_vaapi_encode_init(AVCodecContext *avctx)
static av_cold int init(AVCodecContext *avctx)
static int vaapi_encode_mjpeg_write_extra_buffer(AVCodecContext *avctx, VAAPIEncodePicture *pic, int index, int *type, char *data, size_t *data_len)
av_cold int ff_vaapi_encode_close(AVCodecContext *avctx)
MJPEG encoder and decoder. 
static const unsigned char vaapi_encode_mjpeg_quant_chrominance[64]
unsigned int va_packed_headers
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define av_assert0(cond)
assert() equivalent, that is always enabled. 
const uint8_t avpriv_mjpeg_bits_dc_luminance[17]
static av_cold void vaapi_encode_mjpeg_init_tables(AVCodecContext *avctx)
#define AVERROR_EOF
End of file. 
VASurfaceID recon_surface
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered. 
const uint8_t avpriv_mjpeg_bits_dc_chrominance[17]
int ff_vaapi_encode2(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *input_image, int *got_packet)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static av_cold void vaapi_encode_mjpeg_copy_huffman(unsigned char *dst_lengths, unsigned char *dst_values, const unsigned char *src_lengths, const unsigned char *src_values)
simple assert() macros that are a bit more flexible than ISO C assert(). 
const char * name
Name of the codec implementation. 
VAHuffmanTableBufferJPEGBaseline huffman_tables
void * codec_picture_params
static int put_bits_count(PutBitContext *s)
static const unsigned char vaapi_encode_mjpeg_quant_luminance[64]
common internal API header 
AVCodec ff_mjpeg_vaapi_encoder
static av_cold int vaapi_encode_mjpeg_configure(AVCodecContext *avctx)
int width
picture width / height. 
unsigned int va_rt_format
static int vaapi_encode_mjpeg_write_image_header(AVCodecContext *avctx, VAAPIEncodePicture *pic, VAAPIEncodeSlice *slice, char *data, size_t *data_len)
VAQMatrixBufferJPEG quant_tables
static const AVCodecDefault vaapi_encode_mjpeg_defaults[]
static const AVClass vaapi_encode_mjpeg_class
const struct VAAPIEncodeType * codec
Libavcodec external API header. 
main external API structure. 
int component_subsample_v[3]
const uint8_t avpriv_mjpeg_val_dc[12]
Describe the class of an AVClass context structure. 
const uint8_t avpriv_mjpeg_bits_ac_chrominance[17]
static enum AVPixelFormat pix_fmts[]
const uint8_t avpriv_mjpeg_val_ac_chrominance[]
static void vaapi_encode_mjpeg_write_marker(PutBitContext *pbc, int marker)
int global_quality
Global quality for codecs which cannot change it per frame. 
static int vaapi_encode_mjpeg_init_picture_params(AVCodecContext *avctx, VAAPIEncodePicture *pic)
static int vaapi_encode_mjpeg_init_slice_params(AVCodecContext *avctx, VAAPIEncodePicture *pic, VAAPIEncodeSlice *slice)
common internal api header. 
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros. 
common internal and external API header 
static VAAPIEncodeType vaapi_encode_type_mjpeg
int component_subsample_h[3]
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s. 
const uint8_t avpriv_mjpeg_bits_ac_luminance[17]
const uint8_t avpriv_mjpeg_val_ac_luminance[]
void * codec_slice_params
static av_cold int vaapi_encode_mjpeg_init(AVCodecContext *avctx)
static const AVCodecDefault defaults[]
AVPixelFormat
Pixel format.