History

vaapi_encode_mpeg2: Move common structure into context

Mark Thompson committed 8 years ago

Commit 537d6aa1 parent 2c3ad161 file · +25 −28Browse files

Showing the changes to libavcodec/vaapi_encode_mpeg2.c (1 of 1 file). Show all

Unified · Split

libavcodec/vaapi_encode_mpeg2.c+25−28
@@ -28,6 +28,9 @@ · 27 unmodified lines
28#include "vaapi_encode.h"28#include "vaapi_encode.h"
29 29
30typedef struct VAAPIEncodeMPEG2Context {30typedef struct VAAPIEncodeMPEG2Context {
31 VAAPIEncodeContext common;
32
33 // Derived settings.
31 int mb_width;34 int mb_width;
32 int mb_height;35 int mb_height;
33 36
@@ -35,15 +38,6 @@ typedef struct VAAPIEncodeMPEG2Context { · 1 unmodified line
35 int quant_p;38 int quant_p;
36 int quant_b;39 int quant_b;
37 40
38 MPEG2RawSequenceHeader sequence_header;
39 MPEG2RawExtensionData sequence_extension;
40 MPEG2RawExtensionData sequence_display_extension;
41 MPEG2RawGroupOfPicturesHeader gop_header;
42 MPEG2RawPictureHeader picture_header;
43 MPEG2RawExtensionData picture_coding_extension;
44
45 int64_t last_i_frame;
46
47 unsigned int bit_rate;41 unsigned int bit_rate;
48 unsigned int vbv_buffer_size;42 unsigned int vbv_buffer_size;
49 43
@@ -52,6 +46,17 @@ typedef struct VAAPIEncodeMPEG2Context { · 2 unmodified lines
52 unsigned int f_code_horizontal;46 unsigned int f_code_horizontal;
53 unsigned int f_code_vertical;47 unsigned int f_code_vertical;
54 48
49 // Stream state.
50 int64_t last_i_frame;
51
52 // Writer structures.
53 MPEG2RawSequenceHeader sequence_header;
54 MPEG2RawExtensionData sequence_extension;
55 MPEG2RawExtensionData sequence_display_extension;
56 MPEG2RawGroupOfPicturesHeader gop_header;
57 MPEG2RawPictureHeader picture_header;
58 MPEG2RawExtensionData picture_coding_extension;
59
55 CodedBitstreamContext *cbc;60 CodedBitstreamContext *cbc;
56 CodedBitstreamFragment current_fragment;61 CodedBitstreamFragment current_fragment;
57} VAAPIEncodeMPEG2Context;62} VAAPIEncodeMPEG2Context;
@@ -61,8 +66,7 @@ static int vaapi_encode_mpeg2_write_fragment(AVCodecContext *avctx, · 3 unmodified lines
61 char *data, size_t *data_len,66 char *data, size_t *data_len,
62 CodedBitstreamFragment *frag)67 CodedBitstreamFragment *frag)
63{68{
64 VAAPIEncodeContext *ctx = avctx->priv_data;69 VAAPIEncodeMPEG2Context *priv = avctx->priv_data;
65 VAAPIEncodeMPEG2Context *priv = ctx->priv_data;
66 int err;70 int err;
67 71
68 err = ff_cbs_write_fragment_data(priv->cbc, frag);72 err = ff_cbs_write_fragment_data(priv->cbc, frag);
@@ -88,8 +92,7 @@ static int vaapi_encode_mpeg2_add_header(AVCodecContext *avctx, · 19 unmodified lines
88 CodedBitstreamFragment *frag,92 CodedBitstreamFragment *frag,
89 int type, void *header)93 int type, void *header)
90{94{
91 VAAPIEncodeContext *ctx = avctx->priv_data;95 VAAPIEncodeMPEG2Context *priv = avctx->priv_data;
92 VAAPIEncodeMPEG2Context *priv = ctx->priv_data;
93 int err;96 int err;
94 97
95 err = ff_cbs_insert_unit_content(priv->cbc, frag, -1, type, header, NULL);98 err = ff_cbs_insert_unit_content(priv->cbc, frag, -1, type, header, NULL);
@@ -105,8 +108,7 @@ static int vaapi_encode_mpeg2_add_header(AVCodecContext *avctx, · 9 unmodified lines
105static int vaapi_encode_mpeg2_write_sequence_header(AVCodecContext *avctx,108static int vaapi_encode_mpeg2_write_sequence_header(AVCodecContext *avctx,
106 char *data, size_t *data_len)109 char *data, size_t *data_len)
107{110{
108 VAAPIEncodeContext *ctx = avctx->priv_data;111 VAAPIEncodeMPEG2Context *priv = avctx->priv_data;
109 VAAPIEncodeMPEG2Context *priv = ctx->priv_data;
110 CodedBitstreamFragment *frag = &priv->current_fragment;112 CodedBitstreamFragment *frag = &priv->current_fragment;
111 int err;113 int err;
112 114
@@ -140,8 +142,7 @@ static int vaapi_encode_mpeg2_write_picture_header(AVCodecContext *avctx, · 27 unmodified lines
140 VAAPIEncodePicture *pic,142 VAAPIEncodePicture *pic,
141 char *data, size_t *data_len)143 char *data, size_t *data_len)
142{144{
143 VAAPIEncodeContext *ctx = avctx->priv_data;145 VAAPIEncodeMPEG2Context *priv = avctx->priv_data;
144 VAAPIEncodeMPEG2Context *priv = ctx->priv_data;
145 CodedBitstreamFragment *frag = &priv->current_fragment;146 CodedBitstreamFragment *frag = &priv->current_fragment;
146 int err;147 int err;
147 148
@@ -164,7 +165,7 @@ fail: · 16 unmodified lines
164static int vaapi_encode_mpeg2_init_sequence_params(AVCodecContext *avctx)165static int vaapi_encode_mpeg2_init_sequence_params(AVCodecContext *avctx)
165{166{
166 VAAPIEncodeContext *ctx = avctx->priv_data;167 VAAPIEncodeContext *ctx = avctx->priv_data;
167 VAAPIEncodeMPEG2Context *priv = ctx->priv_data;168 VAAPIEncodeMPEG2Context *priv = avctx->priv_data;
168 MPEG2RawSequenceHeader *sh = &priv->sequence_header;169 MPEG2RawSequenceHeader *sh = &priv->sequence_header;
169 MPEG2RawSequenceExtension *se = &priv->sequence_extension.data.sequence;170 MPEG2RawSequenceExtension *se = &priv->sequence_extension.data.sequence;
170 MPEG2RawSequenceDisplayExtension *sde = &priv->sequence_display_extension.data.sequence_display;171 MPEG2RawSequenceDisplayExtension *sde = &priv->sequence_display_extension.data.sequence_display;
@@ -416,8 +417,7 @@ static int vaapi_encode_mpeg2_init_sequence_params(AVCodecContext *avctx) · 245 unmodified lines
416static int vaapi_encode_mpeg2_init_picture_params(AVCodecContext *avctx,417static int vaapi_encode_mpeg2_init_picture_params(AVCodecContext *avctx,
417 VAAPIEncodePicture *pic)418 VAAPIEncodePicture *pic)
418{419{
419 VAAPIEncodeContext *ctx = avctx->priv_data;420 VAAPIEncodeMPEG2Context *priv = avctx->priv_data;
420 VAAPIEncodeMPEG2Context *priv = ctx->priv_data;
421 MPEG2RawPictureHeader *ph = &priv->picture_header;421 MPEG2RawPictureHeader *ph = &priv->picture_header;
422 MPEG2RawPictureCodingExtension *pce = &priv->picture_coding_extension.data.picture_coding;422 MPEG2RawPictureCodingExtension *pce = &priv->picture_coding_extension.data.picture_coding;
423 VAEncPictureParameterBufferMPEG2 *vpic = pic->codec_picture_params;423 VAEncPictureParameterBufferMPEG2 *vpic = pic->codec_picture_params;
@@ -482,9 +482,8 @@ static int vaapi_encode_mpeg2_init_slice_params(AVCodecContext *avctx, · 58 unmodified lines
482 VAAPIEncodePicture *pic,482 VAAPIEncodePicture *pic,
483 VAAPIEncodeSlice *slice)483 VAAPIEncodeSlice *slice)
484{484{
485 VAAPIEncodeContext *ctx = avctx->priv_data;485 VAAPIEncodeMPEG2Context *priv = avctx->priv_data;
486 VAEncSliceParameterBufferMPEG2 *vslice = slice->codec_slice_params;486 VAEncSliceParameterBufferMPEG2 *vslice = slice->codec_slice_params;
487 VAAPIEncodeMPEG2Context *priv = ctx->priv_data;
488 int qp;487 int qp;
489 488
490 vslice->macroblock_address = priv->mb_width * slice->index;489 vslice->macroblock_address = priv->mb_width * slice->index;
@@ -515,7 +514,7 @@ static int vaapi_encode_mpeg2_init_slice_params(AVCodecContext *avctx, · 24 unmodified lines
515static av_cold int vaapi_encode_mpeg2_configure(AVCodecContext *avctx)514static av_cold int vaapi_encode_mpeg2_configure(AVCodecContext *avctx)
516{515{
517 VAAPIEncodeContext *ctx = avctx->priv_data;516 VAAPIEncodeContext *ctx = avctx->priv_data;
518 VAAPIEncodeMPEG2Context *priv = ctx->priv_data;517 VAAPIEncodeMPEG2Context *priv = avctx->priv_data;
519 int err;518 int err;
520 519
521 err = ff_cbs_init(&priv->cbc, AV_CODEC_ID_MPEG2VIDEO, avctx);520 err = ff_cbs_init(&priv->cbc, AV_CODEC_ID_MPEG2VIDEO, avctx);
@@ -638,11 +637,9 @@ static av_cold int vaapi_encode_mpeg2_init(AVCodecContext *avctx) · 116 unmodified lines
638 637
639static av_cold int vaapi_encode_mpeg2_close(AVCodecContext *avctx)638static av_cold int vaapi_encode_mpeg2_close(AVCodecContext *avctx)
640{639{
641 VAAPIEncodeContext *ctx = avctx->priv_data;640 VAAPIEncodeMPEG2Context *priv = avctx->priv_data;
642 VAAPIEncodeMPEG2Context *priv = ctx->priv_data;
643 641
644 if (priv)642 ff_cbs_close(&priv->cbc);
645 ff_cbs_close(&priv->cbc);
646 643
647 return ff_vaapi_encode_close(avctx);644 return ff_vaapi_encode_close(avctx);
648}645}
@@ -665,7 +662,7 @@ AVCodec ff_mpeg2_vaapi_encoder = { · 16 unmodified lines
665 .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 (VAAPI)"),662 .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 (VAAPI)"),
666 .type = AVMEDIA_TYPE_VIDEO,663 .type = AVMEDIA_TYPE_VIDEO,
667 .id = AV_CODEC_ID_MPEG2VIDEO,664 .id = AV_CODEC_ID_MPEG2VIDEO,
668 .priv_data_size = sizeof(VAAPIEncodeContext),665 .priv_data_size = sizeof(VAAPIEncodeMPEG2Context),
669 .init = &vaapi_encode_mpeg2_init,666 .init = &vaapi_encode_mpeg2_init,
670 .encode2 = &ff_vaapi_encode2,667 .encode2 = &ff_vaapi_encode2,
671 .close = &vaapi_encode_mpeg2_close,668 .close = &vaapi_encode_mpeg2_close,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t