[FFmpeg-devel] Google Summer of Code participation

Stefano Sabatini stefano.sabatini-lala
Sat Apr 4 16:45:22 CEST 2009


On date Saturday 2009-04-04 12:34:53 +0200, Thilo Borgmann encoded:
[...]
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
[...]  
>  /* Decode a subtitle message. Return -1 if error, otherwise return the
>   * number of bytes used. If no subtitle could be decompressed,
> @@ -3100,6 +3129,14 @@ int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
>  int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub,
>                              int *got_sub_ptr,
>                              const uint8_t *buf, int buf_size);

I'd prefer here:

"Wrapper function which calls avcodec_decode_subtitles2()."
This in order to avoid duplication in documentation.

> +
> +/* Decode a subtitle message. Return -1 if error, otherwise return the
> + * number of bytes used. If no subtitle could be decompressed,
> + * got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. */
> +int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
> +                            int *got_sub_ptr,
> +                            AVPacket *avpkt);
> +

Third form is preferred, so "Decodes", "Returns", etc., and while
you're at it maybe you may use the \p prefix for got_sub_ptr and sub,
but maybe this belongs to another commit, so I'd say to leave it as it
is.

[...]
> --- a/libavcodec/fraps.c
> +++ b/libavcodec/fraps.c
> @@ -130,8 +130,10 @@ static int fraps2_decode_plane(FrapsContext *s, uint8_t *dst, int stride, int w,
>   */
>  static int decode_frame(AVCodecContext *avctx,
>                          void *data, int *data_size,
> -                        const uint8_t *buf, int buf_size)
> +                        AVPacket *avpkt)
>  {
> +    const uint8_t *buf = avpkt->data;
> +    int buf_size = avpkt->size;
>      FrapsContext * const s = avctx->priv_data;
>      AVFrame *frame = data;
>      AVFrame * const f = (AVFrame*)&s->frame;
> @@ -345,7 +347,6 @@ static int decode_frame(AVCodecContext *avctx,
>      return buf_size;
>  }
>  
> -
>  /**
>   * closes decoder
>   * @param avctx codec context

Cosmetics.

> @@ -680,6 +682,7 @@ static int ipvideo_decode_frame(AVCodecContext *avctx,
>      return buf_size;
>  }
>  
> +
>  static av_cold int ipvideo_decode_end(AVCodecContext *avctx)
>  {
>      IpvideoContext *s = avctx->priv_data;

Again cosmetics.

> diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c
[...]  
>  
> +
>  static av_cold int decode_close_mp3on4(AVCodecContext * avctx)
>  {

Cosmetics.

[...]
> diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c
> index ad5827e..a40c6d0 100644
> --- a/libavcodec/smacker.c
> +++ b/libavcodec/smacker.c
> @@ -345,8 +345,10 @@ static av_always_inline int smk_get_code(GetBitContext *gb, int *recode, int *la
>      return v;
>  }
>  
> -static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size)
> +static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
>  {
> +    const uint8_t *buf = avpkt->data;
> +    int buf_size = avpkt->size;
>      SmackVContext * const smk = avctx->priv_data;
>      uint8_t *out;
>      uint32_t *pal;
> @@ -500,7 +502,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, const
>  }
>  
>  
> -

ditto.

[...]
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index 4113382..b38031b 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -530,12 +530,25 @@ int attribute_align_arg avcodec_decode_video(AVCodecContext *avctx, AVFrame *pic
>  {
>      int ret;
>  
> +    AVPacket avpkt;
> +    avpkt.data = buf;
> +    avpkt.size = buf_size;
> +
> +    return avcodec_decode_video2(avctx, picture, got_picture_ptr, &avpkt);
> +}

ret is useless.

> +
> +int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
> +                         int *got_picture_ptr,
> +                         AVPacket *avpkt)
> +{
> +    int ret;
> +
>      *got_picture_ptr= 0;
>      if((avctx->coded_width||avctx->coded_height) && avcodec_check_dimensions(avctx,avctx->coded_width,avctx->coded_height))
>          return -1;
> -    if((avctx->codec->capabilities & CODEC_CAP_DELAY) || buf_size){
> +    if((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size){
>          ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
> -                                buf, buf_size);
> +                                avpkt);
>  
>          emms_c(); //needed to avoid an emms_c() call before every return;
>  
> @@ -553,7 +566,20 @@ int attribute_align_arg avcodec_decode_audio2(AVCodecContext *avctx, int16_t *sa
>  {
>      int ret;
>  
> -    if((avctx->codec->capabilities & CODEC_CAP_DELAY) || buf_size){
> +    AVPacket avpkt;
> +    avpkt.data = buf;
> +    avpkt.size = buf_size;
> +
> +    return avcodec_decode_audio3(avctx, samples, frame_size_ptr, &avpkt);
> +}

Ditto.

> +int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,
> +                         int *frame_size_ptr,
> +                         AVPacket *avpkt)
> +{
> +    int ret;
> +
> +    if((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size){
>          //FIXME remove the check below _after_ ensuring that all audio check that the available space is enough
>          if(*frame_size_ptr < AVCODEC_MAX_AUDIO_FRAME_SIZE){
>              av_log(avctx, AV_LOG_ERROR, "buffer smaller than AVCODEC_MAX_AUDIO_FRAME_SIZE\n");
> @@ -565,8 +591,7 @@ int attribute_align_arg avcodec_decode_audio2(AVCodecContext *avctx, int16_t *sa
>              return -1;
>          }
>  
> -        ret = avctx->codec->decode(avctx, samples, frame_size_ptr,
> -                                buf, buf_size);
> +        ret = avctx->codec->decode(avctx, samples, frame_size_ptr, avpkt);
>          avctx->frame_number++;
>      }else{
>          ret= 0;
> @@ -581,9 +606,21 @@ int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub,
>  {
>      int ret;
>  
> +    AVPacket avpkt;
> +    avpkt.data = buf;
> +    avpkt.size = buf_size;
> +
> +    return avcodec_decode_subtitle2(avctx, sub, got_sub_ptr, &avpkt);
> +}

again ret is useless.

[...]
> diff --git a/libavcodec/vcr1.c b/libavcodec/vcr1.c
[...]
> @@ -116,7 +118,6 @@ static int decode_frame(AVCodecContext *avctx,
>  
>      return buf_size;
>  }
> -
>  #if CONFIG_VCR1_ENCODER
>  static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){
>      VCR1Context * const a = avctx->priv_data;

Cosmetics.

[...]

Another cosmetics reindent in pngdec.c (grep for "goto exit_loop").

Regards.
-- 
FFmpeg = Fast & Funny Magic Ponderous Evanescent Gadget



More information about the ffmpeg-devel mailing list