[FFmpeg-cvslog] vaapi_encode_mjpeg: Move common structure into context

Mark Thompson git at videolan.org
Mon Aug 27 21:19:20 EEST 2018


ffmpeg | branch: master | Mark Thompson <sw at jkqxz.net> | Thu Aug 23 00:44:36 2018 +0100| [2c3ad16d3e6eff8c2a119b1a7e0d3e9b3c441f57] | committer: Mark Thompson

vaapi_encode_mjpeg: Move common structure into context

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2c3ad16d3e6eff8c2a119b1a7e0d3e9b3c441f57
---

 libavcodec/vaapi_encode_mjpeg.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/libavcodec/vaapi_encode_mjpeg.c b/libavcodec/vaapi_encode_mjpeg.c
index c949e89646..983c77d194 100644
--- a/libavcodec/vaapi_encode_mjpeg.c
+++ b/libavcodec/vaapi_encode_mjpeg.c
@@ -56,6 +56,8 @@ static const unsigned char vaapi_encode_mjpeg_quant_chrominance[64] = {
 };
 
 typedef struct VAAPIEncodeMJPEGContext {
+    VAAPIEncodeContext common;
+
     int quality;
     int component_subsample_h[3];
     int component_subsample_v[3];
@@ -83,8 +85,7 @@ static av_cold void vaapi_encode_mjpeg_copy_huffman(unsigned char *dst_lengths,
 
 static av_cold void vaapi_encode_mjpeg_init_tables(AVCodecContext *avctx)
 {
-    VAAPIEncodeContext                *ctx = avctx->priv_data;
-    VAAPIEncodeMJPEGContext          *priv = ctx->priv_data;
+    VAAPIEncodeMJPEGContext          *priv = avctx->priv_data;
     VAQMatrixBufferJPEG             *quant = &priv->quant_tables;
     VAHuffmanTableBufferJPEGBaseline *huff = &priv->huffman_tables;
     int i;
@@ -133,10 +134,9 @@ static int vaapi_encode_mjpeg_write_image_header(AVCodecContext *avctx,
                                                  VAAPIEncodeSlice *slice,
                                                  char *data, size_t *data_len)
 {
-    VAAPIEncodeContext               *ctx = avctx->priv_data;
+    VAAPIEncodeMJPEGContext         *priv = avctx->priv_data;
     VAEncPictureParameterBufferJPEG *vpic = pic->codec_picture_params;
     VAEncSliceParameterBufferJPEG *vslice = slice->codec_slice_params;
-    VAAPIEncodeMJPEGContext         *priv = ctx->priv_data;
     PutBitContext pbc;
     int t, i, quant_scale;
 
@@ -242,8 +242,7 @@ static int vaapi_encode_mjpeg_write_extra_buffer(AVCodecContext *avctx,
                                                  int index, int *type,
                                                  char *data, size_t *data_len)
 {
-    VAAPIEncodeContext       *ctx = avctx->priv_data;
-    VAAPIEncodeMJPEGContext *priv = ctx->priv_data;
+    VAAPIEncodeMJPEGContext *priv = avctx->priv_data;
 
     if (index == 0) {
         // Write quantisation tables.
@@ -270,9 +269,8 @@ static int vaapi_encode_mjpeg_write_extra_buffer(AVCodecContext *avctx,
 static int vaapi_encode_mjpeg_init_picture_params(AVCodecContext *avctx,
                                                   VAAPIEncodePicture *pic)
 {
-    VAAPIEncodeContext               *ctx = avctx->priv_data;
+    VAAPIEncodeMJPEGContext         *priv = avctx->priv_data;
     VAEncPictureParameterBufferJPEG *vpic = pic->codec_picture_params;
-    VAAPIEncodeMJPEGContext         *priv = ctx->priv_data;
 
     vpic->reconstructed_picture = pic->recon_surface;
     vpic->coded_buf = pic->output_buffer;
@@ -336,7 +334,7 @@ static int vaapi_encode_mjpeg_init_slice_params(AVCodecContext *avctx,
 static av_cold int vaapi_encode_mjpeg_configure(AVCodecContext *avctx)
 {
     VAAPIEncodeContext       *ctx = avctx->priv_data;
-    VAAPIEncodeMJPEGContext *priv = ctx->priv_data;
+    VAAPIEncodeMJPEGContext *priv = avctx->priv_data;
 
     priv->quality = avctx->global_quality;
     if (priv->quality < 1 || priv->quality > 100) {
@@ -417,7 +415,7 @@ AVCodec ff_mjpeg_vaapi_encoder = {
     .long_name      = NULL_IF_CONFIG_SMALL("MJPEG (VAAPI)"),
     .type           = AVMEDIA_TYPE_VIDEO,
     .id             = AV_CODEC_ID_MJPEG,
-    .priv_data_size = sizeof(VAAPIEncodeContext),
+    .priv_data_size = sizeof(VAAPIEncodeMJPEGContext),
     .init           = &vaapi_encode_mjpeg_init,
     .encode2        = &ff_vaapi_encode2,
     .close          = &ff_vaapi_encode_close,



More information about the ffmpeg-cvslog mailing list