On Tue, Aug 25, 2015 at 11:00:40PM +0300, Ludmila Glinskih wrote: > Add support of floating point decoders. Add support of audio decoders. > --- > tests/api/Makefile | 2 +- > tests/api/api-decode-test.c | 355 > +++++++++++++++++++++++++++++++++++++++++ > tests/api/api-h264-test.c | 166 ------------------- > tests/fate/api.mak | 12 +- > tests/ref/fate/api-decode-h264 | 18 +++ > tests/ref/fate/api-h264 | 18 --- > 6 files changed, 383 insertions(+), 188 deletions(-) > create mode 100644 tests/api/api-decode-test.c > delete mode 100644 tests/api/api-h264-test.c > create mode 100644 tests/ref/fate/api-decode-h264 > delete mode 100644 tests/ref/fate/api-h264 > > diff --git a/tests/api/Makefile b/tests/api/Makefile > index 27f499f..57a7422 100644 > --- a/tests/api/Makefile > +++ b/tests/api/Makefile > @@ -1,5 +1,5 @@ > APITESTPROGS-$(call ENCDEC, FLAC, FLAC) += api-flac > -APITESTPROGS-$(call DEMDEC, H264, H264) += api-h264 > +APITESTPROGS-yes += api-decode > APITESTPROGS-yes += api-seek > APITESTPROGS-$(call DEMDEC, H263, H263) += api-band > APITESTPROGS += $(APITESTPROGS-yes) > diff --git a/tests/api/api-decode-test.c b/tests/api/api-decode-test.c > new file mode 100644 > index 0000000..29c7dd7 > --- /dev/null > +++ b/tests/api/api-decode-test.c > @@ -0,0 +1,355 @@ > +/* > + * Copyright (c) 2015 Ludmila Glinskih > + * > + * Permission is hereby granted, free of charge, to any person obtaining a > copy > + * of this software and associated documentation files (the "Software"), to > deal > + * in the Software without restriction, including without limitation the > rights > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell > + * copies of the Software, and to permit persons to whom the Software is > + * furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be included in > + * all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING > FROM, > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN > + * THE SOFTWARE. > + */ > + > +/** > + * Decode test. > + */ > + > +#include "libavutil/adler32.h" > +#include "libavcodec/avcodec.h" > +#include "libavformat/avformat.h" > +#include "libavutil/imgutils.h" > +#include "libswresample/swresample.h" > +#include "libavutil/opt.h" > + > +static int resample_and_print_data(AVCodecContext *ctx, AVFrame *fr, int > sample_fmt) > +{ > + struct SwrContext *swr_ctx; > + int dst_nb_samples; > + int dst_bufsize; > + int dst_linesize = 0; > + uint8_t **dst_data = NULL; > + int result; > + > + swr_ctx = swr_alloc_set_opts(NULL, > + fr->channel_layout, > + sample_fmt, > + fr->sample_rate, > + fr->channel_layout, > + ctx->sample_fmt, > + fr->sample_rate, > + 0, NULL); > + if (!swr_ctx) { > + av_log(NULL, AV_LOG_ERROR, "Could not allocate resampler context\n"); > + return -1; > + } > + result = swr_init(swr_ctx); > + if (result < 0) { > + av_log(NULL, AV_LOG_ERROR, "Can't initialize the resampling > context\n"); > + return result; > + } > + dst_nb_samples = fr->nb_samples; > + result = av_samples_alloc_array_and_samples(&dst_data, &dst_linesize, > fr->channels, > + dst_nb_samples, sample_fmt, 0); > + if (result < 0) { > + av_log(NULL, AV_LOG_ERROR, "Can't allocate buffer for samples after > resampling\n"); > + return result; > + } > +
> + result = swr_convert(swr_ctx, dst_data, dst_nb_samples, (const uint8_t > **)fr->data, fr->nb_samples); > + if (result < 0) { > + av_log(NULL, AV_LOG_ERROR, "Error while resampling\n"); > + return result; > + } > + > + dst_bufsize = av_samples_get_buffer_size(&dst_linesize, fr->channels, > result, sample_fmt, 1); > + if (dst_bufsize < 0) { > + av_log(NULL, AV_LOG_ERROR, "Can'get buffer size after resampling\n"); > + return dst_bufsize; > + } > + > + fwrite(dst_data[0], 1, dst_bufsize, stdout); this would mismatch on big endian [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User questions about the command line tools should be sent to the ffmpeg-user ML. And questions about how to use libav* should be sent to the libav-user ML.
signature.asc
Description: Digital signature
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel