On Sun, Mar 26, 2017 at 07:11:50PM +0200, Luca Barbato wrote:
> --- a/libavformat/diracdec.c
> +++ b/libavformat/diracdec.c
> @@ -19,9 +19,16 @@
>  
> +#include "libavcodec/dirac.h"
>  #include "libavutil/intreadwrite.h"
> +

#include "libavutil/intreadwrite.h"

#include "libavcodec/dirac.h"

> @@ -31,4 +38,137 @@ static int dirac_probe(AVProbeData *p)
>  
> -FF_DEF_RAWVIDEO_DEMUXER(dirac, "raw Dirac", dirac_probe, NULL, 
> AV_CODEC_ID_DIRAC)
> +static int parse_header(AVFormatContext *s,
> +                        uint32_t *payload_size)

These two lines could be coalesced.

> +{
> +    uint32_t start_code = avio_rl32(s->pb);
> +    uint32_t prev_off, next_off;
> +    int parse_code;
> +
> +    av_log(s, AV_LOG_VERBOSE,
> +           "packet %s next %u prev %u \n",
> +           parse_code == VC2_SEQUENCE_HEADER ? "Sequence Header" :
> +           parse_code == VC2_HQ_PICTURE ? "HQ Picture" :
> +           parse_code == VC2_END_OF_SEQUENCE? "End of Sequence" :

spaces around ?

> +           "Unknown",
> +           next_off,
> +           prev_off);

next_off and prev_off are uint32_t, not unsigned so you should use PRIu32.

> +static int dirac_read_header(AVFormatContext *s)
> +{
> +    AVDiracSeqHeader *dsh;
> +    AVStream *st = avformat_new_stream(s, NULL);
> +    int64_t start = avio_tell(s->pb);
> +
> +    if (!st)
> +        return AVERROR(ENOMEM);

Having another function call before the error check seems suboptimal.

> +    if (!(buf = av_malloc(size)))
> +        return AVERROR(ENOMEM);
> +
> +    if (ret < 0)
> +        goto fail;
> +
> +    if (ret != size) {
> +        ret = AVERROR_EOF;
> +        goto fail;
> +    }
> +
> +    ret = av_dirac_parse_sequence_header(&dsh, buf, size, s);
> +    if (ret < 0)
> +        goto fail;
> +
> +fail:
> +    av_free(buf);
> +    return 0;

I think you leak st in all the above cases.

> +static int next_header(AVFormatContext *s)
> +{
> +    uint32_t size = 0;
> +    int ret = parse_header(s, &size);

Initializing size here seems pointless.

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

Reply via email to