[FFmpeg-devel] [PATCH v2 02/36] vaapi_encode_h264: Move options and common structures into context

Mark Thompson sw at jkqxz.net
Thu Jun 14 00:47:38 EEST 2018


On 11/06/18 07:08, Xiang, Haihao wrote:
> On Fri, 2018-06-08 at 00:42 +0100, Mark Thompson 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 905c50760e..26061974a4 100644
>> --- a/libavcodec/vaapi_encode_h264.c
>> +++ b/libavcodec/vaapi_encode_h264.c
>> ...
>> @@ -206,48 +206,53 @@ static int
>> vaapi_encode_h264_write_extra_header(AVCodecContext *avctx,
>>                                                  int index, int *type,
>>                                                  char *data, size_t *data_len)
>>  {
>> -    VAAPIEncodeContext      *ctx = avctx->priv_data;
>> -    VAAPIEncodeH264Context *priv = ctx->priv_data;
>> +    VAAPIEncodeH264Context *priv = avctx->priv_data;
>>      CodedBitstreamFragment   *au = &priv->current_access_unit;
>>      int err, i;
>>  
>>      if (priv->sei_needed) {
>> +        H264RawSEI *sei = &priv->raw_sei;
>> +
>>          if (priv->aud_needed) {
>> -            err = vaapi_encode_h264_add_nal(avctx, au, &priv->aud);
>> +            err = vaapi_encode_h264_add_nal(avctx, au, &priv->raw_aud);
>>              if (err < 0)
>>                  goto fail;
>>              priv->aud_needed = 0;
>>          }
>>  
>> -        memset(&priv->sei, 0, sizeof(priv->sei));
>> -        priv->sei.nal_unit_header.nal_unit_type = H264_NAL_SEI;
>> +        *sei = (H264RawSEI) {
>> +            .nal_unit_header = {
>> +                .nal_unit_type = H264_NAL_SEI,
>> +            },
>> +        };
>>  
>>          i = 0;
>> +
>>          if (priv->sei_needed & SEI_IDENTIFIER) {
>> -            priv->sei.payload[i].payload_type =
>> H264_SEI_TYPE_USER_DATA_UNREGISTERED;
>> -            priv->sei.payload[i].payload.user_data_unregistered = priv-
>>> identifier;
>> +            sei->payload[i].payload_type =
>> H264_SEI_TYPE_USER_DATA_UNREGISTERED;
>> +            sei->payload[i].payload.user_data_unregistered = priv-
>>> sei_identifier;
>>              ++i;
>>          }
>> -        if (priv->sei_needed & SEI_TIMING) {
>> +        if (priv->sei & SEI_TIMING) {
> 
> 
> Typo? I think timing info is written when it is needed.

Yeah, fixed.

Thanks,

- Mark


More information about the ffmpeg-devel mailing list