Commit afe71d9d authored by Ralph Giles's avatar Ralph Giles Committed by Ralph Giles

Remove the aom_codec_stream_info_t size field.

The aom_codec_stream_info struct had an `sz` field. It looks like
this was intended to implement polymorphism, where individual
codecs under the aom API could extend the struct with additional
members while maintaining common fields like frame size.

However, no codec-specific initializer was ever provided,
requiring callers to manually set this field to the expected
value. The extension mechanism isn't used by the av1 codec,
and also wasn't used by the vp8 or vp9 codecs in the libvpx
implementation.

Since it's not used, this commit removes the layer of indirection,
removing the confusing initialization burden and using
aom_codec_stream_info_t directly within the av1 decoder.

Change-Id: I4372a286b1d03518345c83b01c2f51db6cefe211
parent e4ba6aa3
...@@ -84,11 +84,9 @@ extern "C" { ...@@ -84,11 +84,9 @@ extern "C" {
/*!\brief Stream properties /*!\brief Stream properties
* *
* This structure is used to query or set properties of the decoded * This structure is used to query or set properties of the decoded
* stream. Algorithms may extend this structure with data specific * stream.
* to their bitstream by setting the sz member appropriately.
*/ */
typedef struct aom_codec_stream_info { typedef struct aom_codec_stream_info {
unsigned int sz; /**< Size of this structure */
unsigned int w; /**< Width (or 0 for unknown/default) */ unsigned int w; /**< Width (or 0 for unknown/default) */
unsigned int h; /**< Height (or 0 for unknown/default) */ unsigned int h; /**< Height (or 0 for unknown/default) */
unsigned int is_kf; /**< Current frame is a keyframe */ unsigned int is_kf; /**< Current frame is a keyframe */
...@@ -154,13 +152,15 @@ aom_codec_err_t aom_codec_dec_init_ver(aom_codec_ctx_t *ctx, ...@@ -154,13 +152,15 @@ aom_codec_err_t aom_codec_dec_init_ver(aom_codec_ctx_t *ctx,
* \param[in] iface Pointer to the algorithm interface * \param[in] iface Pointer to the algorithm interface
* \param[in] data Pointer to a block of data to parse * \param[in] data Pointer to a block of data to parse
* \param[in] data_sz Size of the data buffer * \param[in] data_sz Size of the data buffer
* \param[in,out] si Pointer to stream info to update. The size member * \param[in,out] si Pointer to stream info to update.
* \ref MUST be properly initialized, but \ref MAY be
* clobbered by the algorithm. This parameter \ref MAY
* be NULL.
* *
* \retval #AOM_CODEC_OK * \retval #AOM_CODEC_OK
* Bitstream is parsable and stream information updated * Bitstream is parsable and stream information updated.
* \retval #AOM_CODEC_INVALID_PARAM
* One of the arguments is invalid, for example a NULL pointer.
* \retval #AOM_CODEC_UNSUP_BITSTREAM
* The decoder didn't recognize the coded data, or the
* buffer was too short.
*/ */
aom_codec_err_t aom_codec_peek_stream_info(aom_codec_iface_t *iface, aom_codec_err_t aom_codec_peek_stream_info(aom_codec_iface_t *iface,
const uint8_t *data, const uint8_t *data,
...@@ -172,13 +172,14 @@ aom_codec_err_t aom_codec_peek_stream_info(aom_codec_iface_t *iface, ...@@ -172,13 +172,14 @@ aom_codec_err_t aom_codec_peek_stream_info(aom_codec_iface_t *iface,
* Returns information about the stream that has been parsed during decoding. * Returns information about the stream that has been parsed during decoding.
* *
* \param[in] ctx Pointer to this instance's context * \param[in] ctx Pointer to this instance's context
* \param[in,out] si Pointer to stream info to update. The size member * \param[in,out] si Pointer to stream info to update.
* \ref MUST be properly initialized, but \ref MAY be
* clobbered by the algorithm. This parameter \ref MAY
* be NULL.
* *
* \retval #AOM_CODEC_OK * \retval #AOM_CODEC_OK
* Bitstream is parsable and stream information updated * Bitstream is parsable and stream information updated.
* \retval #AOM_CODEC_INVALID_PARAM
* One of the arguments is invalid, for example a NULL pointer.
* \retval #AOM_CODEC_UNSUP_BITSTREAM
* The decoder couldn't parse the submitted data.
*/ */
aom_codec_err_t aom_codec_get_stream_info(aom_codec_ctx_t *ctx, aom_codec_err_t aom_codec_get_stream_info(aom_codec_ctx_t *ctx,
aom_codec_stream_info_t *si); aom_codec_stream_info_t *si);
......
...@@ -69,10 +69,9 @@ aom_codec_err_t aom_codec_peek_stream_info(aom_codec_iface_t *iface, ...@@ -69,10 +69,9 @@ aom_codec_err_t aom_codec_peek_stream_info(aom_codec_iface_t *iface,
aom_codec_stream_info_t *si) { aom_codec_stream_info_t *si) {
aom_codec_err_t res; aom_codec_err_t res;
if (!iface || !data || !data_sz || !si || if (!iface || !data || !data_sz || !si) {
si->sz < sizeof(aom_codec_stream_info_t))
res = AOM_CODEC_INVALID_PARAM; res = AOM_CODEC_INVALID_PARAM;
else { } else {
/* Set default/unknown values */ /* Set default/unknown values */
si->w = 0; si->w = 0;
si->h = 0; si->h = 0;
...@@ -87,11 +86,11 @@ aom_codec_err_t aom_codec_get_stream_info(aom_codec_ctx_t *ctx, ...@@ -87,11 +86,11 @@ aom_codec_err_t aom_codec_get_stream_info(aom_codec_ctx_t *ctx,
aom_codec_stream_info_t *si) { aom_codec_stream_info_t *si) {
aom_codec_err_t res; aom_codec_err_t res;
if (!ctx || !si || si->sz < sizeof(aom_codec_stream_info_t)) if (!ctx || !si) {
res = AOM_CODEC_INVALID_PARAM; res = AOM_CODEC_INVALID_PARAM;
else if (!ctx->iface || !ctx->priv) } else if (!ctx->iface || !ctx->priv) {
res = AOM_CODEC_ERROR; res = AOM_CODEC_ERROR;
else { } else {
/* Set default/unknown values */ /* Set default/unknown values */
si->w = 0; si->w = 0;
si->h = 0; si->h = 0;
......
...@@ -312,8 +312,6 @@ static int file_is_raw(struct AvxInputContext *input) { ...@@ -312,8 +312,6 @@ static int file_is_raw(struct AvxInputContext *input) {
int is_raw = 0; int is_raw = 0;
aom_codec_stream_info_t si; aom_codec_stream_info_t si;
si.sz = sizeof(si);
if (fread(buf, 1, 32, input->file) == 32) { if (fread(buf, 1, 32, input->file) == 32) {
int i; int i;
......
...@@ -31,8 +31,6 @@ ...@@ -31,8 +31,6 @@
#include "av1/av1_iface_common.h" #include "av1/av1_iface_common.h"
typedef aom_codec_stream_info_t av1_stream_info_t;
// This limit is due to framebuffer numbers. // This limit is due to framebuffer numbers.
// TODO(hkuang): Remove this limit after implementing ondemand framebuffers. // TODO(hkuang): Remove this limit after implementing ondemand framebuffers.
#define FRAME_CACHE_SIZE 6 // Cache maximum 6 decoded frames. #define FRAME_CACHE_SIZE 6 // Cache maximum 6 decoded frames.
...@@ -45,7 +43,7 @@ typedef struct cache_frame { ...@@ -45,7 +43,7 @@ typedef struct cache_frame {
struct aom_codec_alg_priv { struct aom_codec_alg_priv {
aom_codec_priv_t base; aom_codec_priv_t base;
aom_codec_dec_cfg_t cfg; aom_codec_dec_cfg_t cfg;
av1_stream_info_t si; aom_codec_stream_info_t si;
int postproc_cfg_set; int postproc_cfg_set;
aom_postproc_cfg_t postproc_cfg; aom_postproc_cfg_t postproc_cfg;
aom_decrypt_cb decrypt_cb; aom_decrypt_cb decrypt_cb;
...@@ -101,7 +99,6 @@ static aom_codec_err_t decoder_init(aom_codec_ctx_t *ctx, ...@@ -101,7 +99,6 @@ static aom_codec_err_t decoder_init(aom_codec_ctx_t *ctx,
ctx->priv = (aom_codec_priv_t *)priv; ctx->priv = (aom_codec_priv_t *)priv;
ctx->priv->init_flags = ctx->init_flags; ctx->priv->init_flags = ctx->init_flags;
priv->si.sz = sizeof(priv->si);
priv->flushed = 0; priv->flushed = 0;
// Only do frame parallel decode when threads > 1. // Only do frame parallel decode when threads > 1.
priv->frame_parallel_decode = priv->frame_parallel_decode =
...@@ -263,11 +260,7 @@ static aom_codec_err_t decoder_peek_si(const uint8_t *data, ...@@ -263,11 +260,7 @@ static aom_codec_err_t decoder_peek_si(const uint8_t *data,
static aom_codec_err_t decoder_get_si(aom_codec_alg_priv_t *ctx, static aom_codec_err_t decoder_get_si(aom_codec_alg_priv_t *ctx,
aom_codec_stream_info_t *si) { aom_codec_stream_info_t *si) {
const size_t sz = (si->sz >= sizeof(av1_stream_info_t)) memcpy(si, &ctx->si, sizeof(*si));
? sizeof(av1_stream_info_t)
: sizeof(aom_codec_stream_info_t);
memcpy(si, &ctx->si, sz);
si->sz = (unsigned int)sz;
return AOM_CODEC_OK; return AOM_CODEC_OK;
} }
......
...@@ -82,8 +82,6 @@ void DecoderTest::RunLoop(CompressedVideoSource *video, ...@@ -82,8 +82,6 @@ void DecoderTest::RunLoop(CompressedVideoSource *video,
PreDecodeFrameHook(*video, decoder); PreDecodeFrameHook(*video, decoder);
aom_codec_stream_info_t stream_info; aom_codec_stream_info_t stream_info;
stream_info.sz = sizeof(stream_info);
if (video->cxdata() != NULL) { if (video->cxdata() != NULL) {
const aom_codec_err_t res_peek = decoder->PeekStream( const aom_codec_err_t res_peek = decoder->PeekStream(
video->cxdata(), video->frame_size(), &stream_info); video->cxdata(), video->frame_size(), &stream_info);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment