On 2014-02-23 23:59:25 +0100, Luca Barbato wrote:
> ---
> 
> Reviews in patch update form please.
> 
>  libavcodec/parser.c | 187 
> ++++++++++++++++++++++++++++------------------------
>  1 file changed, 102 insertions(+), 85 deletions(-)
> 
> diff --git a/libavcodec/parser.c b/libavcodec/parser.c
> index 511f1f3..18969d0 100644
> --- a/libavcodec/parser.c
> +++ b/libavcodec/parser.c
> @@ -143,16 +146,17 @@ int av_parser_parse2(AVCodecParserContext *s,
>              s->cur_frame_pos[i] = pos;
>      }
> 
> -    if (s->fetch_timestamp){
> -        s->fetch_timestamp=0;
> -        s->last_pts = s->pts;
> -        s->last_dts = s->dts;
> -        s->last_pos = s->pos;
> +    if (s->fetch_timestamp) {
> +        s->fetch_timestamp = 0;
> +        s->last_pts        = s->pts;
> +        s->last_dts        = s->dts;
> +        s->last_pos        = s->pos;
>          ff_fetch_timestamp(s, 0, 0);
>      }
> -
>      /* WARNING: the returned index can be negative */
> -    index = s->parser->parser_parse(s, avctx, (const uint8_t **)poutbuf, 
> poutbuf_size, buf, buf_size);
> +    index = s->parser->parser_parse(s, avctx,
> +                                    (const uint8_t **)poutbuf, poutbuf_size,
> +                                    buf, buf_size);

that looks like it would fit in two lines

>      /* update the file pointer */
>      if (*poutbuf_size) {
>          /* fill the data for the current frame */
> @@ -171,29 +175,33 @@ int av_parser_parse2(AVCodecParserContext *s,
>  int av_parser_change(AVCodecParserContext *s,
>                       AVCodecContext *avctx,
>                       uint8_t **poutbuf, int *poutbuf_size,
> -                     const uint8_t *buf, int buf_size, int keyframe){
> -
> -    if(s && s->parser->split){
> -        if((avctx->flags & CODEC_FLAG_GLOBAL_HEADER) || (avctx->flags2 & 
> CODEC_FLAG2_LOCAL_HEADER)){
> -            int i= s->parser->split(avctx, buf, buf_size);
> -            buf += i;
> +                     const uint8_t *buf, int buf_size, int keyframe)
> +{
> +    if (s && s->parser->split) {
> +        if ((avctx->flags & CODEC_FLAG_GLOBAL_HEADER) ||
> +            (avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER)) {
> +            int i = s->parser->split(avctx, buf, buf_size);
> +            buf      += i;
>              buf_size -= i;
>          }
>      }
> 
>      /* cast to avoid warning about discarding qualifiers */
> -    *poutbuf= (uint8_t *) buf;
> -    *poutbuf_size= buf_size;
> -    if(avctx->extradata){
> -        if(  (keyframe && (avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER))
> +    *poutbuf      = (uint8_t *)buf;
> +    *poutbuf_size = buf_size;
> +    if (avctx->extradata) {
> +        if ((keyframe && (avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER))
>              /*||(s->pict_type != AV_PICTURE_TYPE_I && (s->flags & 
> PARSER_FLAG_DUMP_EXTRADATA_AT_NOKEY))*/
> -            /*||(? && (s->flags & PARSER_FLAG_DUMP_EXTRADATA_AT_BEGIN)*/){
> -            int size= buf_size + avctx->extradata_size;
> -            *poutbuf_size= size;
> -            *poutbuf= av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
> +            /*||(? && (s->flags & PARSER_FLAG_DUMP_EXTRADATA_AT_BEGIN)*/) {
> +            int size = buf_size + avctx->extradata_size;
> +
> +            *poutbuf_size = size;
> +            *poutbuf      = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
> 
>              memcpy(*poutbuf, avctx->extradata, avctx->extradata_size);
> -            memcpy((*poutbuf) + avctx->extradata_size, buf, buf_size + 
> FF_INPUT_BUFFER_PADDING_SIZE);
> +            memcpy((*poutbuf) + avctx->extradata_size,
> +                   buf,
> +                   buf_size + FF_INPUT_BUFFER_PADDING_SIZE);

that should fit also in two lines

>              return 1;
>          }
>      }
> @@ -211,33 +219,37 @@ void av_parser_close(AVCodecParserContext *s)
>      }
>  }
> 
> -/*****************************************************/
> -
> -int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int 
> *buf_size)
> +int ff_combine_frame(ParseContext *pc, int next,
> +                     const uint8_t **buf, int *buf_size)
>  {
> -    if(pc->overread){
> +    if (pc->overread) {
>          av_dlog(NULL, "overread %d, state:%X next:%d index:%d o_index:%d\n",
>                  pc->overread, pc->state, next, pc->index, 
> pc->overread_index);
> -        av_dlog(NULL, "%X %X %X %X\n", (*buf)[0], (*buf)[1], (*buf)[2], 
> (*buf)[3]);
> +        av_dlog(NULL, "%X %X %X %X\n",
> +                (*buf)[0],
> +                (*buf)[1],
> +                (*buf)[2],
> +                (*buf)[3]);

two lines are enough

> @@ -245,34 +257,39 @@ int ff_combine_frame(ParseContext *pc, int next, const 
> uint8_t **buf, int *buf_s
>          return -1;
>      }
> 
> -    *buf_size=
> -    pc->overread_index= pc->index + next;
> +    *buf_size = pc->overread_index = pc->index + next;
> 
>      /* append to buffer */
> -    if(pc->index){
> -        void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, 
> next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
> +    if (pc->index) {
> +        void *new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size,
> +                                           next + pc->index +
> +                                           FF_INPUT_BUFFER_PADDING_SIZE);
> 
> -        if(!new_buffer)
> +        if (!new_buffer)
>              return AVERROR(ENOMEM);
>          pc->buffer = new_buffer;
>          if (next > -FF_INPUT_BUFFER_PADDING_SIZE)
>              memcpy(&pc->buffer[pc->index], *buf,
>                     next + FF_INPUT_BUFFER_PADDING_SIZE);
>          pc->index = 0;
> -        *buf= pc->buffer;
> +        *buf      = pc->buffer;
>      }
> 
>      /* store overread bytes */
> -    for(;next < 0; next++){
> -        pc->state = (pc->state<<8) | pc->buffer[pc->last_index + next];
> -        pc->state64 = (pc->state64<<8) | pc->buffer[pc->last_index + next];
> +    for (; next < 0; next++) {
> +        pc->state   = (pc->state << 8) | pc->buffer[pc->last_index + next];
> +        pc->state64 = (pc->state64 << 8) | pc->buffer[pc->last_index + next];
>          pc->overread++;
>      }
> 
> -    if(pc->overread){
> +    if (pc->overread) {
>          av_dlog(NULL, "overread %d, state:%X next:%d index:%d o_index:%d\n",
>                  pc->overread, pc->state, next, pc->index, 
> pc->overread_index);
> -        av_dlog(NULL, "%X %X %X %X\n", (*buf)[0], 
> (*buf)[1],(*buf)[2],(*buf)[3]);
> +        av_dlog(NULL, "%X %X %X %X\n",
> +                (*buf)[0],
> +                (*buf)[1],
> +                (*buf)[2],
> +                (*buf)[3]);

see above

ommitted parts are ok

Janne
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to