#define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL)
#define f(width, name) \
- xf(width, name, current->name, 0)
+ xf(width, name, current->name, 0, )
#define s(width, name) \
- xs(width, name, current->name, 0)
+ xs(width, name, current->name, 0, )
#define fs(width, name, subs, ...) \
xf(width, name, current->name, subs, __VA_ARGS__)
#define ss(width, name, subs, ...) \
xs(width, name, current->name, subs, __VA_ARGS__)
-
#define READ
#define READWRITE read
#define RWContext GetBitContext
#define delta_q(name) do { \
uint8_t delta_coded; \
int8_t delta_q; \
- xf(1, name.delta_coded, delta_coded, 0); \
+ xf(1, name.delta_coded, delta_coded, 0, ); \
if (delta_coded) \
- xs(4, name.delta_q, delta_q, 0); \
+ xs(4, name.delta_q, delta_q, 0, ); \
else \
delta_q = 0; \
current->name = delta_q; \
} while (0)
#define delta_q(name) do { \
- xf(1, name.delta_coded, !!current->name, 0); \
+ xf(1, name.delta_coded, !!current->name, 0, ); \
if (current->name) \
- xs(4, name.delta_q, current->name, 0); \
+ xs(4, name.delta_q, current->name, 0, ); \
} while (0)
#define prob(name, subs, ...) do { \
uint8_t superframe_header;
int err;
+ if (frag->data_size == 0)
+ return AVERROR_INVALIDDATA;
+
// Last byte in the packet.
superframe_header = frag->data[frag->data_size - 1];
return AVERROR_INVALIDDATA;
}
- err = ff_cbs_insert_unit_data(ctx, frag, -1, 0,
+ err = ff_cbs_insert_unit_data(frag, -1, 0,
frag->data + pos,
sfi.frame_sizes[i],
frag->data_ref);
return 0;
} else {
- err = ff_cbs_insert_unit_data(ctx, frag, -1, 0,
+ err = ff_cbs_insert_unit_data(frag, -1, 0,
frag->data, frag->data_size,
frag->data_ref);
if (err < 0)
return 0;
}
-static void cbs_vp9_free_frame(void *opaque, uint8_t *content)
-{
- VP9RawFrame *frame = (VP9RawFrame*)content;
- av_buffer_unref(&frame->data_ref);
- av_freep(&frame);
-}
-
static int cbs_vp9_read_unit(CodedBitstreamContext *ctx,
CodedBitstreamUnit *unit)
{
if (err < 0)
return err;
- err = ff_cbs_alloc_unit_content(ctx, unit, sizeof(*frame),
- &cbs_vp9_free_frame);
+ err = ff_cbs_alloc_unit_content2(ctx, unit);
if (err < 0)
return err;
frame = unit->content;
return 0;
}
+static void cbs_vp9_flush(CodedBitstreamContext *ctx)
+{
+ CodedBitstreamVP9Context *vp9 = ctx->priv_data;
+
+ memset(vp9->ref, 0, sizeof(vp9->ref));
+}
+
+static const CodedBitstreamUnitTypeDescriptor cbs_vp9_unit_types[] = {
+ CBS_UNIT_TYPE_INTERNAL_REF(0, VP9RawFrame, data),
+ CBS_UNIT_TYPE_END_OF_LIST
+};
+
const CodedBitstreamType ff_cbs_type_vp9 = {
.codec_id = AV_CODEC_ID_VP9,
.priv_data_size = sizeof(CodedBitstreamVP9Context),
+ .unit_types = cbs_vp9_unit_types,
+
.split_fragment = &cbs_vp9_split_fragment,
.read_unit = &cbs_vp9_read_unit,
.write_unit = &cbs_vp9_write_unit,
+
+ .flush = &cbs_vp9_flush,
+
.assemble_fragment = &cbs_vp9_assemble_fragment,
};