[FFmpeg-devel] [PATCH 01/26] vaapi_encode_h264: Move options and common structures into context

Mark Thompson sw at jkqxz.net
Thu Apr 26 01:05:56 EEST 2018


On 25/04/18 08:02, Xiang, Haihao wrote:>> This will make it easier to support options in common between different
>> encoders.  It also cleans up some of the field naming.
>> ---
>>  libavcodec/vaapi_encode_h264.c | 228 +++++++++++++++++++++-------------------
>> -
>>  1 file changed, 115 insertions(+), 113 deletions(-)
>>
>> diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
>> index 56ad217b4a..cc163151a6 100644
>> --- a/libavcodec/vaapi_encode_h264.c
>> +++ b/libavcodec/vaapi_encode_h264.c
>> ...
>> @@ -882,16 +888,15 @@ static const VAAPIEncodeType vaapi_encode_type_h264 = {
>>  
>>  static av_cold int vaapi_encode_h264_init(AVCodecContext *avctx)
>>  {
>> -    VAAPIEncodeContext     *ctx = avctx->priv_data;
>> -    VAAPIEncodeH264Options *opt =
>> -        (VAAPIEncodeH264Options*)ctx->codec_options_data;
>> +    VAAPIEncodeContext      *ctx = avctx->priv_data;
>> +    VAAPIEncodeH264Context *priv = avctx->priv_data;
>>  
> 
> How about to replace *ctx = avctx->priv_data with ctx = &priv->common? (Of
> course priv should be assigned first). The latter is more readable for me.
> Actually I was confused at little bit at first glance because both priv and ctx
> are avtctx->priv_data.

I don't think so?  They are the same pointer with different types, so we load them with the same value.  Indirecting one of them through the other makes it look like they aren't the same pointer, which feels more confusing to me.

- Mark


More information about the ffmpeg-devel mailing list