[FFmpeg-devel] [PATCH] ALS decoder
Michael Niedermayer
michaelni
Wed Oct 21 14:13:02 CEST 2009
On Wed, Oct 21, 2009 at 12:50:16PM +0200, Thilo Borgmann wrote:
> Michael Niedermayer schrieb:
> > On Thu, Sep 24, 2009 at 05:03:14PM +0200, Thilo Borgmann wrote:
> >> Revision 23 attached.
> >
> > [...]
> >> +/** Reformat block sizes from log2 format to direct form. Also assure that the
> >> + * block sizes of the last frame correspond to the actual number of samples.
> >> + */
> >> +static void reconstruct_block_sizes(ALSDecContext *ctx, uint32_t *div_blocks)
> >> +{
> >> + unsigned int b;
> >> +
> >> + // The last frame may have an overdetermined block structure given in
> >> + // the bitstream. In that case the defined block structure would need
> >> + // more samples than available to be consistent.
> >> + // The block structure is actually used but the block sizes are adapted
> >> + // to fit the actual number of available samples.
> >> + // Example: 5 samples, 2nd level block sizes: 2 2 2 2.
> >> + // This results in the actual block sizes: 2 2 1 0.
> >> + // This is not specified in 14496-3 but actually done by the reference
> >> + // codec RM22 revision 2.
> >> + // This appears to happen in case of an odd number of samples in the last
> >> + // frame which is actually not allowed by the block length switching part
> >> + // of 14496-3.
> >> + // The ALS conformance files feature an odd number of samples in the last
> >> + // frame.
> >> +
> >> + for (b = 0; b < ctx->num_blocks; b++)
> >> + div_blocks[b] = ctx->sconf.frame_length >> div_blocks[b];
> >> +
> >> + if (ctx->cur_frame_length == ctx->last_frame_length) {
> >
> > if(ctx->cur_frame_length != ctx->sconf.frame_length) {
> > and last_frame_length becomes removeable
> >
>
> Yes.
>
> >
> > [...]
> >> +/** Decodes an ALS frame.
> >> + */
> >> +static int decode_frame(AVCodecContext *avctx,
> >> + void *data, int *data_size,
> >> + AVPacket *avpkt)
> >> +{
> >> + ALSDecContext *ctx = avctx->priv_data;
> >> + ALSSpecificConfig *sconf = &ctx->sconf;
> >> + const uint8_t *buffer = avpkt->data;
> >> + int buffer_size = avpkt->size;
> >> + int invalid_frame, size;
> >> + unsigned int c, sample, ra_frame, bytes_read, shift;
> >> +
> >> + init_get_bits(&ctx->gb, buffer, buffer_size * 8);
> >> +
> >> + // In the case that the distance between random access frames is set to zero
> >> + // (sconf->ra_distance == 0) no frame is treated as a random access frame.
> >> + // For the first frame, if prediction is used, all samples used from the
> >> + // previous frame are assumed to be zero.
> >> + ra_frame = sconf->ra_distance && !(ctx->frame_id % sconf->ra_distance);
> >> +
> >
> >
> >> + // the last frame to decode might have a different length
> >> + if (ctx->num_frames && ctx->num_frames - 1 == ctx->frame_id)
> >> + ctx->cur_frame_length = ctx->last_frame_length;
> >
> > ctx->cur_frame_length= FFMIN(samples - ctx->frame_id*(uint64_t)sconf->frame_length, sconf->frame_length);
> > and ctx->num_frames becomes unneeded and can be removed
>
> Isn't this way slower than before?
how large are frames? i thought they are large enough for 1 multiply & MIN
not to matter ...
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Avoid a single point of failure, be that a person or equipment.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20091021/7989e016/attachment.pgp>
More information about the ffmpeg-devel
mailing list