On 03/18/2012 09:58 PM, Paul B Mahol wrote:
>
> Signed-off-by: Paul B Mahol <[email protected]>
> ---
> doc/general.texi | 2 +
> libavcodec/Makefile | 1 +
> libavcodec/allcodecs.c | 1 +
> libavcodec/avcodec.h | 1 +
> libavcodec/version.h | 2 +-
> libavcodec/vima.c | 272
> ++++++++++++++++++++++++++++++++++++++++++++++++
> 6 files changed, 278 insertions(+), 1 deletions(-)
> create mode 100644 libavcodec/vima.c
[...]
> + for (table_pos = 0, dest_pos = start_pos;
> + table_pos < sizeof(step_table) / sizeof(step_table[0]);
see FF_ARRAY_ELEMS()
[...]
> + if (bytestream2_get_bytes_left(&gb) < 13)
> + return -1;
return AVERROR_INVALIDDATA
error message would be nice too
> +
> + samples = bytestream2_get_be32u(&gb);
> + if (samples < 0) {
> + bytestream2_skip(&gb, 4);
> + samples = bytestream2_get_be32u(&gb);
> + }
The behavior of the unsigned int to signed int cast is
implementation-defined. Now might be a nice time to add a general
solution for this...
> +
> + channel_hint[0] = bytestream2_get_byteu(&gb);
> + if (channel_hint[0] & 0x80) {
> + channel_hint[0] = ~channel_hint[0];
> + channels = 2;
> + }
> + avctx->channels = channels;
Please also set channel_layout.
> + pcm_data[0] = bytestream2_get_be16u(&gb);
> + if (channels > 1) {
> + channel_hint[1] = bytestream2_get_byte(&gb);
> + pcm_data[1] = bytestream2_get_be16(&gb);
> + }
> + bits = bytestream2_get_be16(&gb);
> +
> + vima->frame.nb_samples = samples;
> + if ((ret = avctx->get_buffer(avctx, &vima->frame)) < 0) {
> + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
> + return ret;
> + }
> + dest = vima->frame.data[0];
> +
> + for (chan = 0; chan < channels; chan++) {
> + uint8_t *destPos = dest + chan;
[...]
> +
> + bytestream_put_be16(&destPos, outputWord);
Frame data is supposed to be native-endian. This looks like you're
writing it in big-endian. What is the reason for not using the native
sample type of int16_t for dest?
Thanks,
Justin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel