[FFmpeg-devel] [PATCH] Bitstream filter DTS from any format to 14bit format.
Måns Rullgård
mans
Tue Aug 4 22:29:55 CEST 2009
Bartlomiej Wolowiec <bartek.wolowiec at gmail.com> writes:
> Hi,
> Here is a small bitstream filter, which may be useful for someone.
> --
> Bartlomiej Wolowiec
>
[...]
> +static int dts14b_filter(AVBitStreamFilterContext * bsfc,
> + AVCodecContext * avctx, const char *args,
> + uint8_t ** poutbuf, int *poutbuf_size,
> + const uint8_t * buf, int buf_size, int keyframe)
> +{
> + GetBitContext gb;
> + int dca_buffer_size;
> + uint8_t dca_buffer[DCA_MAX_FRAME_SIZE];
> + uint16_t *pout;
> +
> + dca_buffer_size =
> + ff_dca_convert_bitstream(buf, buf_size, dca_buffer,
> + DCA_MAX_FRAME_SIZE);
> + if (dca_buffer_size == -1) {
> + av_log(avctx, AV_LOG_ERROR, "Not a valid DCA frame\n");
> + return -1;
> + }
> +
> + *poutbuf_size = ((dca_buffer_size + 13) / 14) << 4;
> + *poutbuf = av_malloc(*poutbuf_size + FF_INPUT_BUFFER_PADDING_SIZE);
> + pout = (uint16_t *) * poutbuf;
Doesn't gcc complain about strict aliasing violations here?
> + init_get_bits(&gb, dca_buffer, dca_buffer_size);
> + while (get_bits_count(&gb) < dca_buffer_size << 3) {
> + uint16_t tmp = get_bits(&gb, 14);
> + if (tmp > 0x1FFF)
> + tmp |= 0xC000;
get_sbits()
> + *(pout++) = be2me_16(tmp);
Useless ()
> + }
> +
> + while (((uint8_t *) pout - *poutbuf) & 7)
> + *(pout++) = 0;
What's all this padding for?
> +
> + return 0;
> +}
> +
> +AVBitStreamFilter dts14b_bsf = {
> + "dts14b",
> + 0,
> + dts14b_filter,
> +};
--
M?ns Rullg?rd
mans at mansr.com
More information about the ffmpeg-devel
mailing list