On Sun, Nov 8, 2015 at 8:57 PM, Anton Khirnov <[email protected]> wrote:
> Also, stop using AVCodecContext for storing the stream parameters.
> ---
> configure | 4 +-
> doc/APIchanges | 4 +-
> libavcodec/Makefile | 2 +
> libavcodec/dirac.c | 223
> ++++++++++++++++++++++++++++----------------
> libavcodec/dirac.h | 33 ++++++-
> libavformat/oggparsedirac.c | 31 ++++--
> 6 files changed, 200 insertions(+), 97 deletions(-)
>
> - ff_set_sar(avctx, avctx->sample_aspect_ratio);
> + if (ret = parse_source_parameters(dsh, &gb, log_ctx))
> + goto fail;
if ((ret = parse_source_parameters(dsh, &gb, log_ctx)) < 0) maybe?
> /* [DIRAC_STD] picture_coding_mode shall be 0 for fields and 1 for frames
> * currently only used to signal field coding */
> - picture_coding_mode = svq3_get_ue_golomb(gb);
> + picture_coding_mode = svq3_get_ue_golomb(&gb);
> if (picture_coding_mode != 0) {
> - av_log(avctx, AV_LOG_ERROR, "Unsupported picture coding mode %d",
> - picture_coding_mode);
> - return AVERROR_INVALIDDATA;
> + if (log_ctx) {
> + av_log(log_ctx, AV_LOG_ERROR, "Unsupported picture coding mode
> %d",
> + picture_coding_mode);
> + }
> + ret = AVERROR_INVALIDDATA;
> + goto fail;
> }
> +
> + *pdsh = dsh;
> return 0;
> +fail:
> + av_freep(&dsh);
> + *pdsh = NULL;
> + return ret;
> +}
> +#else
> +int av_dirac_parse_sequence_header(AVDiracSeqHeader **pdsh,
> + const uint8_t *buf, size_t buf_size,
> + void *log_ctx)
> +{
> + return AVERROR(ENOSYS);
> }
> +#endif
> diff --git a/libavcodec/dirac.h b/libavcodec/dirac.h
> index e5b79b0..25cefdb 100644
> --- a/libavcodec/dirac.h
> +++ b/libavcodec/dirac.h
> @@ -29,9 +29,8 @@
> */
>
> #include "avcodec.h"
> -#include "get_bits.h"
>
> -typedef struct dirac_source_params {
> +typedef struct AVDiracSeqHeader {
> unsigned width;
> unsigned height;
> uint8_t chroma_format; ///< 0: 444 1: 422 2: 420
> @@ -49,9 +48,33 @@ typedef struct dirac_source_params {
>
> uint8_t pixel_range_index; ///< index into
> dirac_pixel_range_presets[]
> uint8_t color_spec_index; ///< index into
> dirac_color_spec_presets[]
> -} dirac_source_params;
>
> -int avpriv_dirac_parse_sequence_header(AVCodecContext *avctx, GetBitContext
> *gb,
> - dirac_source_params *source);
> + int profile;
> + int level;
> +
> + AVRational framerate;
> + AVRational sample_aspect_ratio;
> +
> + enum AVPixelFormat pix_fmt;
> + enum AVColorRange color_range;
> + enum AVColorPrimaries color_primaries;
> + enum AVColorTransferCharacteristic color_trc;
> + enum AVColorSpace colorspace;
> +} AVDiracSeqHeader;
> +
> +/**
> + * Parse a Dirac sequence header.
> + *
> + * @param dsh this function will allocate and fill an AVDiracSeqHeader struct
> + * and write it into this pointer. The caller must free it with
> + * av_free().
> + * @param buf the data buffer
> + * @param buf_size the size of the data buffer in bytes
> + * @param log_ctx if non-NULL, this function will log errors here
> + * @return 0 on success, a negative AVERROR code on failure
> + */
> +int av_dirac_parse_sequence_header(AVDiracSeqHeader **dsh,
> + const uint8_t *buf, size_t buf_size,
> + void *log_ctx);
>
> #endif /* AVCODEC_DIRAC_H */
seems fine
--
Vittorio
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel