Thanks for getting back to this decoder!
On Mon, Jan 21, 2013 at 08:25:39PM +0100, Jordi Ortiz wrote:
> ---
> Use VideoDSPContext.emulated_edge_mc() instead of ff_emultated_edge_mc_8()
> Use the ff_get_buffer() wrapper.
>
> Changelog | 1 +
> configure | 1 +
> doc/general.texi | 5 +-
> libavcodec/Makefile | 3 +
> libavcodec/allcodecs.c | 1 +
> libavcodec/dirac_arith.c | 115 +++
> libavcodec/dirac_arith.h | 166 ++++
> libavcodec/diracdec.c | 2014
> ++++++++++++++++++++++++++++++++++++++++++++++
> libavcodec/version.h | 2 +-
> 9 files changed, 2305 insertions(+), 3 deletions(-)
> create mode 100644 libavcodec/dirac_arith.c
> create mode 100644 libavcodec/dirac_arith.h
> create mode 100644 libavcodec/diracdec.c
What is the status of this decoder now? Does it still produce artifacts?
If yes, for which cases?
> --- a/Changelog
> +++ b/Changelog
> @@ -16,6 +16,7 @@ version 9_beta3:
> - multi-channel ALAC encoding up to 7.1
> - TAK demuxer, parser, and decoder
> - adaptive frame-level multithreading for H.264
> +- Native dirac decoder
native
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -120,6 +120,7 @@ void avcodec_register_all(void)
> REGISTER_DECODER(CSCD, cscd);
> REGISTER_DECODER(CYUV, cyuv);
> REGISTER_DECODER(DFA, dfa);
> + REGISTER_DECODER (DIRAC, dirac);
> REGISTER_ENCDEC (DNXHD, dnxhd);
> REGISTER_ENCDEC (DPX, dpx);
> REGISTER_DECODER(DSICINVIDEO, dsicinvideo);
Keep this neatly aligned like the rest.
> --- /dev/null
> +++ b/libavcodec/dirac_arith.h
> @@ -0,0 +1,166 @@
> +
> +#ifndef AVCODEC_DIRAC_ARITH_H
> +#define AVCODEC_DIRAC_ARITH_H
> +
> +#include "bytestream.h"
> +#include "get_bits.h"
This does not appear to use anything from get_bits.h.
> --- /dev/null
> +++ b/libavcodec/diracdec.c
> @@ -0,0 +1,2014 @@
> +
> +static void dirac_decode_flush(AVCodecContext *avctx)
> +{
> + DiracContext *s = avctx->priv_data;
> + free_sequence_buffers(s);
> + s->seen_sequence_header = 0;
> + s->frame_number = -1;
> +}
> +
> +static av_cold int dirac_decode_end(AVCodecContext *avctx)
> +{
> + dirac_decode_flush(avctx);
> + return 0;
> +}
Why the indirection?
> +/* [DIRAC_STD] 11.2 Picture prediction data. picture_prediction()
> + * Unpack the motion compensation parameters. */
> +static int dirac_unpack_prediction_parameters(DiracContext *s)
> +{
> + if (FFMAX(s->plane[0].xblen, s->plane[0].yblen) > DIRAC_MAX_BLOCKSIZE) {
> + av_log(s->avctx, AV_LOG_ERROR, "Unsupported large block size\n");
> + return AVERROR_PATCHWELCOME;
Is this a candidate for av_log_missing_feature or av_log_patch_welcome?
> +/* [DIRAC_STD] 11.1.1 Picture Header. picture_header() */
> +static int dirac_decode_picture_header(DiracContext *s)
> +{
> + int retire, picnum;
> + int i, j, refnum, refdist, ret, distance;
> + GetBitContext *gb = &s->gb;
> +
> + /* [DIRAC_STD] 11.1.1 Picture Header. picture_header() PICTURE_NUM */
> + picnum =
> + s->current_picture->avframe.display_picture_number =
> + get_bits_long(gb, 32);
> + picnum = s->current_picture->avframe.display_picture_number =
> get_bits_long(gb, 32);
nit:
picnum =
s->current_picture->avframe.display_picture_number = get_bits_long(gb, 32);
> + /* if there were no references at all, allocate one */
> + if (!s->ref_pics[i])
> + for (j = 0; j < DIRAC_MAX_FRAMES; j++)
> + if (!s->all_frames[j].avframe.data[0]) {
> + s->ref_pics[i] = &s->all_frames[j];
> + if (ff_get_buffer(s->avctx, &s->ref_pics[i]->avframe) <
> 0) {
> + av_log(s->avctx, AV_LOG_ERROR,
> + "Unable to allocate new frame\n");
> + return AVERROR_BUG;
Propagate the return value instead.
> +static int dirac_decode_data_unit(AVCodecContext *avctx, const uint8_t *buf,
> + int size)
> +{
> + if (ff_get_buffer(avctx, &pic->avframe) < 0) {
> + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
> + return AVERROR_BUG;
same
Please check if there are more instances of ff_get_buffer that I missed.
> +static int dirac_decode_frame(AVCodecContext *avctx, void *data,
> + int *data_size, AVPacket *pkt)
> +{
> + DiracContext *s = avctx->priv_data;
> + DiracFrame *picture = data;
> + uint8_t *buf = pkt->data;
> + int buf_size = pkt->size;
> + int i, data_unit_size, ret, buf_idx = 0;
> +
> + /* release unused frames */
> + for (i = 0; i < DIRAC_MAX_FRAMES; i++)
> + if (s->all_frames[i].avframe.data[0]
> + && !s->all_frames[i].avframe.reference) {
nit: Move the && to the previous line.
Diego
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel