diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-05-07 22:42:41 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-05-07 22:51:34 +0200 |
commit | 653d117c29123d353ce3bdd7de71e830a26733c1 (patch) | |
tree | 996ad2bd13c774dc3265cbf0d8ae406372d57307 | |
parent | cb982739fa2b43afb7f1262c07804cad41f778de (diff) | |
parent | fdc918632f5c16cf377a2170cd2f101933fb15ff (diff) | |
download | ffmpeg-653d117c29123d353ce3bdd7de71e830a26733c1.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
libschroedinger: Switch to function names more in line with Libav style.
Move code shared between libdirac and libschroedinger to libschroedinger.
lavfi: uninline avfilter_copy_buffer_ref_props().
lavf: add missing '*' in a doxy.
h264: Remove a commented-out function pointer typedef.
txd: Remove write-only variable in txd_decode_frame().
mmvideo.c: Remove unused variable in mm_decode_pal().
build: cosmetics: Add missing end-of-line backslashes to item lists.
build: cosmetics: Split HEADERS/OBJS/PROGS lists into one entry per line.
libschroedinger: Move a function to avoid a forward declaration.
pthread: warn on high thread counts
vf_yadif: fix missing error handling for avfilter_poll_frame()
avprobe: allow showing only one container/stream property.
lavfi: support audio in avfilter_copy_frame_props().
lavfi: avfilter_merge_formats: handle case where inputs are same
lavc: add sample rate and channel layout to AVFrame.
zerocodec: check if the previous frame is missing
doc: clarify check for NULL pointer style
Conflicts:
doc/APIchanges
doc/developer.texi
ffprobe.c
libavcodec/Makefile
libavcodec/avcodec.h
libavcodec/libdirac_libschro.c
libavcodec/libdirac_libschro.h
libavcodec/mmvideo.c
libavcodec/txd.c
libavcodec/version.h
libavcodec/zerocodec.c
libavfilter/Makefile
libavfilter/avfilter.c
libavfilter/version.h
libavformat/Makefile
libavutil/Makefile
Merged-by: Michael Niedermayer <michaelni@gmx.at>
31 files changed, 374 insertions, 340 deletions
diff --git a/doc/ffprobe.texi b/doc/ffprobe.texi index 12fe29f01f..47c215634d 100644 --- a/doc/ffprobe.texi +++ b/doc/ffprobe.texi @@ -106,6 +106,11 @@ stream. All the container format information is printed within a section with name "FORMAT". +@item -show_format_entry @var{name} +Like @option{-show_format}, but only prints the specified entry of the +container format information, rather than all. This option may be given more +than once, then all specified entries will be shown. + @item -show_packets Show information about each packet contained in the input multimedia stream. @@ -50,6 +50,7 @@ static int do_read_packets = 0; static int do_show_error = 0; static int do_show_format = 0; static int do_show_frames = 0; +static AVDictionary *fmt_entries_to_show = NULL; static int do_show_packets = 0; static int do_show_streams = 0; static int do_show_program_version = 0; @@ -81,6 +82,7 @@ static uint64_t *nb_streams_frames; void av_noreturn exit_program(int ret) { + av_dict_free(&fmt_entries_to_show); exit(ret); } @@ -279,8 +281,10 @@ static inline void writer_print_section_footer(WriterContext *wctx, static inline void writer_print_integer(WriterContext *wctx, const char *key, long long int val) { - wctx->writer->print_integer(wctx, key, val); - wctx->nb_item++; + if (!fmt_entries_to_show || (key && av_dict_get(fmt_entries_to_show, key, NULL, 0))) { + wctx->writer->print_integer(wctx, key, val); + wctx->nb_item++; + } } static inline void writer_print_string(WriterContext *wctx, @@ -288,8 +292,10 @@ static inline void writer_print_string(WriterContext *wctx, { if (opt && !(wctx->writer->flags & WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS)) return; - wctx->writer->print_string(wctx, key, val); - wctx->nb_item++; + if (!fmt_entries_to_show || (key && av_dict_get(fmt_entries_to_show, key, NULL, 0))) { + wctx->writer->print_string(wctx, key, val); + wctx->nb_item++; + } } static void writer_print_time(WriterContext *wctx, const char *key, @@ -297,12 +303,14 @@ static void writer_print_time(WriterContext *wctx, const char *key, { char buf[128]; - if (ts == AV_NOPTS_VALUE) { - writer_print_string(wctx, key, "N/A", 1); - } else { - double d = ts * av_q2d(*time_base); - value_string(buf, sizeof(buf), (struct unit_value){.val.d=d, .unit=unit_second_str}); - writer_print_string(wctx, key, buf, 0); + if (!fmt_entries_to_show || (key && av_dict_get(fmt_entries_to_show, key, NULL, 0))) { + if (ts == AV_NOPTS_VALUE) { + writer_print_string(wctx, key, "N/A", 1); + } else { + double d = ts * av_q2d(*time_base); + value_string(buf, sizeof(buf), (struct unit_value){.val.d=d, .unit=unit_second_str}); + writer_print_string(wctx, key, buf, 0); + } } } @@ -1428,6 +1436,20 @@ static void show_streams(WriterContext *w, AVFormatContext *fmt_ctx) show_stream(w, fmt_ctx, i); } +static void print_format_entry(const char *tag, + const char *val) +{ + if (!fmt_entries_to_show) { + if (tag) { + printf("%s=%s\n", tag, val); + } else { + printf("%s\n", val); + } + } else if (tag && av_dict_get(fmt_entries_to_show, tag, NULL, 0)) { + printf("%s=%s\n", tag, val); + } +} + static void show_format(WriterContext *w, AVFormatContext *fmt_ctx) { char val_str[128]; @@ -1621,6 +1643,13 @@ static int opt_format(const char *opt, const char *arg) return 0; } +static int opt_show_format_entry(const char *opt, const char *arg) +{ + do_show_format = 1; + av_dict_set(&fmt_entries_to_show, arg, "", 0); + return 0; +} + static void opt_input_file(void *optctx, const char *arg) { if (input_filename) { @@ -1678,6 +1707,8 @@ static const OptionDef options[] = { { "show_error", OPT_BOOL, {(void*)&do_show_error} , "show probing error" }, { "show_format", OPT_BOOL, {(void*)&do_show_format} , "show format/container info" }, { "show_frames", OPT_BOOL, {(void*)&do_show_frames} , "show frames info" }, + { "show_format_entry", HAS_ARG, {(void*)opt_show_format_entry}, + "show a particular entry from the format/container info", "entry" }, { "show_packets", OPT_BOOL, {(void*)&do_show_packets}, "show packets info" }, { "show_streams", OPT_BOOL, {(void*)&do_show_streams}, "show streams info" }, { "count_frames", OPT_BOOL, {(void*)&do_count_frames}, "count the number of frames per stream" }, diff --git a/libavcodec/Makefile b/libavcodec/Makefile index a39ec88e06..df4d908dd3 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -3,7 +3,14 @@ include $(SUBDIR)../config.mak NAME = avcodec FFLIBS = avutil -HEADERS = avcodec.h avfft.h dxva2.h vaapi.h vda.h vdpau.h version.h xvmc.h +HEADERS = avcodec.h \ + avfft.h \ + dxva2.h \ + vaapi.h \ + vda.h \ + vdpau.h \ + version.h \ + xvmc.h \ OBJS = allcodecs.o \ audioconvert.o \ @@ -651,11 +658,9 @@ OBJS-$(CONFIG_LIBOPENCORE_AMRWB_DECODER) += libopencore-amr.o OBJS-$(CONFIG_LIBOPENJPEG_DECODER) += libopenjpegdec.o OBJS-$(CONFIG_LIBOPENJPEG_ENCODER) += libopenjpegenc.o OBJS-$(CONFIG_LIBSCHROEDINGER_DECODER) += libschroedingerdec.o \ - libschroedinger.o \ - libdirac_libschro.o + libschroedinger.o OBJS-$(CONFIG_LIBSCHROEDINGER_ENCODER) += libschroedingerenc.o \ - libschroedinger.o \ - libdirac_libschro.o + libschroedinger.o OBJS-$(CONFIG_LIBSPEEX_DECODER) += libspeexdec.o OBJS-$(CONFIG_LIBSPEEX_ENCODER) += libspeexenc.o audio_frame_queue.o OBJS-$(CONFIG_LIBSTAGEFRIGHT_H264_DECODER)+= libstagefright.o @@ -753,7 +758,8 @@ SKIPHEADERS += %_tablegen.h \ aac_tablegen_decl.h \ fft-internal.h \ tableprint.h \ - $(ARCH)/vp56_arith.h + $(ARCH)/vp56_arith.h \ + SKIPHEADERS-$(CONFIG_DXVA2) += dxva2.h dxva2_internal.h SKIPHEADERS-$(CONFIG_LIBSCHROEDINGER) += libschroedinger.h SKIPHEADERS-$(CONFIG_MPEG_XVMC_DECODER) += xvmc.h @@ -762,13 +768,28 @@ SKIPHEADERS-$(CONFIG_VDA) += vda_internal.h SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h SKIPHEADERS-$(HAVE_W32THREADS) += w32pthreads.h -TESTPROGS = cabac dct fft fft-fixed golomb iirfilter rangecoder snowenc +TESTPROGS = cabac \ + dct \ + fft \ + fft-fixed \ + golomb \ + iirfilter \ + rangecoder \ + snowenc \ + TESTPROGS-$(HAVE_MMX) += motion TESTOBJS = dctref.o -HOSTPROGS = aac_tablegen aacps_tablegen cbrt_tablegen cos_tablegen \ - dv_tablegen motionpixels_tablegen mpegaudio_tablegen \ - pcm_tablegen qdm2_tablegen sinewin_tablegen +HOSTPROGS = aac_tablegen \ + aacps_tablegen \ + cbrt_tablegen \ + cos_tablegen \ + dv_tablegen \ + motionpixels_tablegen \ + mpegaudio_tablegen \ + pcm_tablegen \ + qdm2_tablegen \ + sinewin_tablegen \ CLEANFILES = *_tables.c *_tables.h *_tablegen$(HOSTEXESUF) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index db17917b8a..21bd60881b 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1243,6 +1243,22 @@ typedef struct AVFrame { uint8_t motion_subsample_log2; /** + * Sample rate of the audio data. + * + * - encoding: unused + * - decoding: read by user + */ + int sample_rate; + + /** + * Channel layout of the audio data. + * + * - encoding: unused + * - decoding: read by user. + */ + uint64_t channel_layout; + + /** * frame timestamp estimated using various heuristics, in stream time base * Code outside libavcodec should access this field using: * av_frame_get_best_effort_timestamp(frame) @@ -1260,24 +1276,6 @@ typedef struct AVFrame { */ int64_t pkt_pos; - /** - * channel layout of the audio frame - * - encoding: unused - * - decoding: read by user. - * Code outside libavcodec should access this field using: - * av_frame_get_channel_layout(frame) - */ - int64_t channel_layout; - - /** - * sample rate of the audio frame - * - encoding: unused - * - decoding: read by user. - * Code outside libavcodec should access this field using: - * av_frame_get_channel_layout(frame) - */ - int sample_rate; - } AVFrame; /** diff --git a/libavcodec/h264dsp.h b/libavcodec/h264dsp.h index 490a936310..d7c192012a 100644 --- a/libavcodec/h264dsp.h +++ b/libavcodec/h264dsp.h @@ -30,7 +30,6 @@ #include <stdint.h> #include "dsputil.h" -//typedef void (*h264_chroma_mc_func)(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int srcStride, int h, int x, int y); typedef void (*h264_weight_func)(uint8_t *block, int stride, int height, int log2_denom, int weight, int offset); typedef void (*h264_biweight_func)(uint8_t *dst, uint8_t *src, int stride, int height, diff --git a/libavcodec/libdirac_libschro.c b/libavcodec/libdirac_libschro.c deleted file mode 100644 index c8657e2fd2..0000000000 --- a/libavcodec/libdirac_libschro.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2008 BBC, Anuradha Suraparaju <asuraparaju at gmail dot com > - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** -* @file -* functions common to libdirac and libschroedinger -*/ - -#include "libdirac_libschro.h" - -static const DiracSchroVideoFormatInfo ff_dirac_schro_video_format_info[] = { - { 640, 480, 24000, 1001}, - { 176, 120, 15000, 1001}, - { 176, 144, 25, 2 }, - { 352, 240, 15000, 1001}, - { 352, 288, 25, 2 }, - { 704, 480, 15000, 1001}, - { 704, 576, 25, 2 }, - { 720, 480, 30000, 1001}, - { 720, 576, 25, 1 }, - { 1280, 720, 60000, 1001}, - { 1280, 720, 50, 1 }, - { 1920, 1080, 30000, 1001}, - { 1920, 1080, 25, 1 }, - { 1920, 1080, 60000, 1001}, - { 1920, 1080, 50, 1 }, - { 2048, 1080, 24, 1 }, - { 4096, 2160, 24, 1 }, -}; - -unsigned int ff_dirac_schro_get_video_format_idx(AVCodecContext *avccontext) -{ - unsigned int ret_idx = 0; - unsigned int idx; - unsigned int num_formats = sizeof(ff_dirac_schro_video_format_info) / - sizeof(ff_dirac_schro_video_format_info[0]); - - for (idx = 1; idx < num_formats; ++idx) { - const DiracSchroVideoFormatInfo *vf = &ff_dirac_schro_video_format_info[idx]; - if (avccontext->width == vf->width && - avccontext->height == vf->height) { - ret_idx = idx; - if (avccontext->time_base.den == vf->frame_rate_num && - avccontext->time_base.num == vf->frame_rate_denom) - return idx; - } - } - return ret_idx; -} - -void ff_dirac_schro_queue_init(DiracSchroQueue *queue) -{ - queue->p_head = queue->p_tail = NULL; - queue->size = 0; -} - -void ff_dirac_schro_queue_free(DiracSchroQueue *queue, - void (*free_func)(void *)) -{ - while (queue->p_head) - free_func(ff_dirac_schro_queue_pop(queue)); -} - -int ff_dirac_schro_queue_push_back(DiracSchroQueue *queue, void *p_data) -{ - DiracSchroQueueElement *p_new = av_mallocz(sizeof(DiracSchroQueueElement)); - - if (!p_new) - return -1; - - p_new->data = p_data; - - if (!queue->p_head) - queue->p_head = p_new; - else - queue->p_tail->next = p_new; - queue->p_tail = p_new; - - ++queue->size; - return 0; -} - -void *ff_dirac_schro_queue_pop(DiracSchroQueue *queue) -{ - DiracSchroQueueElement *top = queue->p_head; - - if (top) { - void *data = top->data; - queue->p_head = queue->p_head->next; - --queue->size; - av_freep(&top); - return data; - } - - return NULL; -} diff --git a/libavcodec/libdirac_libschro.h b/libavcodec/libdirac_libschro.h deleted file mode 100644 index aecdb30e76..0000000000 --- a/libavcodec/libdirac_libschro.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2008 BBC, Anuradha Suraparaju <asuraparaju at gmail dot com > - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** -* @file -* data structures common to libdirac and libschroedinger -*/ - -#ifndef AVCODEC_LIBDIRAC_LIBSCHRO_H -#define AVCODEC_LIBDIRAC_LIBSCHRO_H - -#include "avcodec.h" - -typedef struct { - uint16_t width; - uint16_t height; - uint16_t frame_rate_num; - uint16_t frame_rate_denom; -} DiracSchroVideoFormatInfo; - -/** -* Returns the index into the Dirac Schro common video format info table -*/ -unsigned int ff_dirac_schro_get_video_format_idx(AVCodecContext *avccontext); - -/** -* contains a single encoded frame returned from Dirac or Schroedinger -*/ -typedef struct DiracSchroEncodedFrame { - /** encoded frame data */ - uint8_t *p_encbuf; - - /** encoded frame size */ - uint32_t size; - - /** encoded frame number. Will be used as pts */ - uint32_t frame_num; - - /** key frame flag. 1 : is key frame , 0 : in not key frame */ - uint16_t key_frame; -} DiracSchroEncodedFrame; - -/** -* queue element -*/ -typedef struct DiracSchroQueueElement { - /** Data to be stored in queue*/ - void *data; - /** Pointer to next element queue */ - struct DiracSchroQueueElement *next; -} DiracSchroQueueElement; - - -/** -* A simple queue implementation used in libdirac and libschroedinger -*/ -typedef struct DiracSchroQueue { - /** Pointer to head of queue */ - DiracSchroQueueElement *p_head; - /** Pointer to tail of queue */ - DiracSchroQueueElement *p_tail; - /** Queue size*/ - int size; -} DiracSchroQueue; - -/** -* Initialise the queue -*/ -void ff_dirac_schro_queue_init(DiracSchroQueue *queue); - -/** -* Add an element to the end of the queue -*/ -int ff_dirac_schro_queue_push_back(DiracSchroQueue *queue, void *p_data); - -/** -* Return the first element in the queue -*/ -void *ff_dirac_schro_queue_pop(DiracSchroQueue *queue); - -/** -* Free the queue resources. free_func is a function supplied by the caller to -* free any resources allocated by the caller. The data field of the queue -* element is passed to it. -*/ -void ff_dirac_schro_queue_free(DiracSchroQueue *queue, - void (*free_func)(void *)); -#endif /* AVCODEC_LIBDIRAC_LIBSCHRO_H */ diff --git a/libavcodec/libschroedinger.c b/libavcodec/libschroedinger.c index a2ea5ddbdc..631035e240 100644 --- a/libavcodec/libschroedinger.c +++ b/libavcodec/libschroedinger.c @@ -23,12 +23,97 @@ * function definitions common to libschroedinger decoder and encoder */ -#include "libdirac_libschro.h" #include "libschroedinger.h" +static const SchroVideoFormatInfo ff_schro_video_format_info[] = { + { 640, 480, 24000, 1001}, + { 176, 120, 15000, 1001}, + { 176, 144, 25, 2 }, + { 352, 240, 15000, 1001}, + { 352, 288, 25, 2 }, + { 704, 480, 15000, 1001}, + { 704, 576, 25, 2 }, + { 720, 480, 30000, 1001}, + { 720, 576, 25, 1 }, + { 1280, 720, 60000, 1001}, + { 1280, 720, 50, 1 }, + { 1920, 1080, 30000, 1001}, + { 1920, 1080, 25, 1 }, + { 1920, 1080, 60000, 1001}, + { 1920, 1080, 50, 1 }, + { 2048, 1080, 24, 1 }, + { 4096, 2160, 24, 1 }, +}; + +static unsigned int get_video_format_idx(AVCodecContext *avccontext) +{ + unsigned int ret_idx = 0; + unsigned int idx; + unsigned int num_formats = sizeof(ff_schro_video_format_info) / + sizeof(ff_schro_video_format_info[0]); + + for (idx = 1; idx < num_formats; ++idx) { + const SchroVideoFormatInfo *vf = &ff_schro_video_format_info[idx]; + if (avccontext->width == vf->width && + avccontext->height == vf->height) { + ret_idx = idx; + if (avccontext->time_base.den == vf->frame_rate_num && + avccontext->time_base.num == vf->frame_rate_denom) + return idx; + } + } + return ret_idx; +} + +void ff_schro_queue_init(FFSchroQueue *queue) +{ + queue->p_head = queue->p_tail = NULL; + queue->size = 0; +} + +void ff_schro_queue_free(FFSchroQueue *queue, void (*free_func)(void *)) +{ + while (queue->p_head) + free_func(ff_schro_queue_pop(queue)); +} + +int ff_schro_queue_push_back(FFSchroQueue *queue, void *p_data) +{ + FFSchroQueueElement *p_new = av_mallocz(sizeof(FFSchroQueueElement)); + + if (!p_new) + return -1; + + p_new->data = p_data; + + if (!queue->p_head) + queue->p_head = p_new; + else + queue->p_tail->next = p_new; + queue->p_tail = p_new; + + ++queue->size; + return 0; +} + +void *ff_schro_queue_pop(FFSchroQueue *queue) +{ + FFSchroQueueElement *top = queue->p_head; + + if (top) { + void *data = top->data; + queue->p_head = queue->p_head->next; + --queue->size; + av_freep(&top); + return data; + } + + return NULL; +} + /** * Schroedinger video preset table. Ensure that this tables matches up correctly -* with the ff_dirac_schro_video_format_info table in libdirac_libschro.c. +* with the ff_schro_video_format_info table. */ static const SchroVideoFormatEnum ff_schro_video_formats[]={ SCHRO_VIDEO_FORMAT_CUSTOM , @@ -55,7 +140,7 @@ SchroVideoFormatEnum ff_get_schro_video_format_preset(AVCodecContext *avccontext unsigned int num_formats = sizeof(ff_schro_video_formats) / sizeof(ff_schro_video_formats[0]); - unsigned int idx = ff_dirac_schro_get_video_format_idx (avccontext); + unsigned int idx = get_video_format_idx(avccontext); return (idx < num_formats) ? ff_schro_video_formats[idx] : SCHRO_VIDEO_FORMAT_CUSTOM; @@ -78,7 +163,7 @@ int ff_get_schro_frame_format (SchroChromaFormat schro_pix_fmt, return -1; } -static void FreeSchroFrame(SchroFrame *frame, void *priv) +static void free_schro_frame(SchroFrame *frame, void *priv) { AVPicture *p_pic = priv; @@ -110,7 +195,7 @@ SchroFrame *ff_create_schro_frame(AVCodecContext *avccontext, p_frame->format = schro_frame_fmt; p_frame->width = y_width; p_frame->height = y_height; - schro_frame_set_free_callback(p_frame, FreeSchroFrame, (void *)p_pic); + schro_frame_set_free_callback(p_frame, free_schro_frame, (void *)p_pic); for (i = 0; i < 3; ++i) { p_frame->components[i].width = i ? uv_width : y_width; diff --git a/libavcodec/libschroedinger.h b/libavcodec/libschroedinger.h index 262e0220bf..bacc0da050 100644 --- a/libavcodec/libschroedinger.h +++ b/libavcodec/libschroedinger.h @@ -28,8 +28,78 @@ #include <schroedinger/schrobitstream.h> #include <schroedinger/schroframe.h> + #include "avcodec.h" +typedef struct { + uint16_t width; + uint16_t height; + uint16_t frame_rate_num; + uint16_t frame_rate_denom; +} SchroVideoFormatInfo; + +/** +* contains a single encoded frame returned from Dirac or Schroedinger +*/ +typedef struct FFSchroEncodedFrame { + /** encoded frame data */ + uint8_t *p_encbuf; + + /** encoded frame size */ + uint32_t size; + + /** encoded frame number. Will be used as pts */ + uint32_t frame_num; + + /** key frame flag. 1 : is key frame , 0 : in not key frame */ + uint16_t key_frame; +} FFSchroEncodedFrame; + +/** +* queue element +*/ +typedef struct FFSchroQueueElement { + /** Data to be stored in queue*/ + void *data; + /** Pointer to next element queue */ + struct FFSchroQueueElement *next; +} FFSchroQueueElement; + + +/** +* A simple queue implementation used in libschroedinger +*/ +typedef struct FFSchroQueue { + /** Pointer to head of queue */ + FFSchroQueueElement *p_head; + /** Pointer to tail of queue */ + FFSchroQueueElement *p_tail; + /** Queue size*/ + int size; +} FFSchroQueue; + +/** +* Initialise the queue +*/ +void ff_schro_queue_init(FFSchroQueue *queue); + +/** +* Add an element to the end of the queue +*/ +int ff_schro_queue_push_back(FFSchroQueue *queue, void *p_data); + +/** +* Return the first element in the queue +*/ +void *ff_schro_queue_pop(FFSchroQueue *queue); + +/** +* Free the queue resources. free_func is a function supplied by the caller to +* free any resources allocated by the caller. The data field of the queue +* element is passed to it. +*/ +void ff_schro_queue_free(FFSchroQueue *queue, void (*free_func)(void *)); + static const struct { enum PixelFormat ff_pix_fmt; SchroChromaFormat schro_pix_fmt; diff --git a/libavcodec/libschroedingerdec.c b/libavcodec/libschroedingerdec.c index bd20c40d15..4929eecb28 100644 --- a/libavcodec/libschroedingerdec.c +++ b/libavcodec/libschroedingerdec.c @@ -29,7 +29,6 @@ #include "libavutil/imgutils.h" #include "avcodec.h" -#include "libdirac_libschro.h" #include "libschroedinger.h" #undef NDEBUG @@ -52,7 +51,7 @@ typedef struct SchroDecoderParams { SchroDecoder* decoder; /** queue storing decoded frames */ - DiracSchroQueue dec_frame_queue; + FFSchroQueue dec_frame_queue; /** end of sequence signalled */ int eos_signalled; @@ -71,16 +70,19 @@ typedef struct SchroParseUnitContext { static void libschroedinger_decode_buffer_free(SchroBuffer *schro_buf, - void *priv); + void *priv) +{ + av_freep(&priv); +} -static void SchroParseContextInit(SchroParseUnitContext *parse_ctx, - const uint8_t *buf, int buf_size) +static void parse_context_init(SchroParseUnitContext *parse_ctx, + const uint8_t *buf, int buf_size) { parse_ctx->buf = buf; parse_ctx->buf_size = buf_size; } -static SchroBuffer *FindNextSchroParseUnit(SchroParseUnitContext *parse_ctx) +static SchroBuffer *find_next_parse_unit(SchroParseUnitContext *parse_ctx) { SchroBuffer *enc_buf = NULL; int next_pu_offset = 0; @@ -152,16 +154,10 @@ static av_cold int libschroedinger_decode_init(AVCodecContext *avccontext) return -1; /* Initialize the decoded frame queue. */ - ff_dirac_schro_queue_init(&p_schro_params->dec_frame_queue); + ff_schro_queue_init(&p_schro_params->dec_frame_queue); return 0; } -static void libschroedinger_decode_buffer_free(SchroBuffer *schro_buf, - void *priv) -{ - av_freep(&priv); -} - static void libschroedinger_decode_frame_free(void *frame) { schro_frame_unref(frame); @@ -223,7 +219,7 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext, *data_size = 0; - SchroParseContextInit(&parse_ctx, buf, buf_size); + parse_context_init(&parse_ctx, buf, buf_size); if (!buf_size) { if (!p_schro_params->eos_signalled) { state = schro_decoder_push_end_of_stream(decoder); @@ -233,7 +229,7 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext, /* Loop through all the individual parse units in the input buffer */ do { - if ((enc_buf = FindNextSchroParseUnit(&parse_ctx))) { + if ((enc_buf = find_next_parse_unit(&parse_ctx))) { /* Push buffer into decoder. */ if (SCHRO_PARSE_CODE_IS_PICTURE(enc_buf->data[4]) && SCHRO_PARSE_CODE_NUM_REFS(enc_buf->data[4]) > 0) @@ -270,8 +266,8 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext, frame = schro_decoder_pull(decoder); if (frame) - ff_dirac_schro_queue_push_back(&p_schro_params->dec_frame_queue, - frame); + ff_schro_queue_push_back(&p_schro_params->dec_frame_queue, + frame); break; case SCHRO_DECODER_EOS: go = 0; @@ -288,7 +284,7 @@ static int libschroedinger_decode_frame(AVCodecContext *avccontext, } while (outer); /* Grab next frame to be returned from the top of the queue. */ - frame = ff_dirac_schro_queue_pop(&p_schro_params->dec_frame_queue); + frame = ff_schro_queue_pop(&p_schro_params->dec_frame_queue); if (frame) { memcpy(p_schro_params->dec_pic.data[0], @@ -327,8 +323,8 @@ static av_cold int libschroedinger_decode_close(AVCodecContext *avccontext) avpicture_free(&p_schro_params->dec_pic); /* Free data in the output frame queue. */ - ff_dirac_schro_queue_free(&p_schro_params->dec_frame_queue, - libschroedinger_decode_frame_free); + ff_schro_queue_free(&p_schro_params->dec_frame_queue, + libschroedinger_decode_frame_free); return 0; } @@ -340,10 +336,10 @@ static void libschroedinger_flush(AVCodecContext *avccontext) SchroDecoderParams *p_schro_params = avccontext->priv_data; /* Free data in the output frame queue. */ - ff_dirac_schro_queue_free(&p_schro_params->dec_frame_queue, - libschroedinger_decode_frame_free); + ff_schro_queue_free(&p_schro_params->dec_frame_queue, + libschroedinger_decode_frame_free); - ff_dirac_schro_queue_init(&p_schro_params->dec_frame_queue); + ff_schro_queue_init(&p_schro_params->dec_frame_queue); schro_decoder_reset(p_schro_params->decoder); p_schro_params->eos_pulled = 0; p_schro_params->eos_signalled = 0; diff --git a/libavcodec/libschroedingerenc.c b/libavcodec/libschroedingerenc.c index 71c4fd8955..0cea5a7194 100644 --- a/libavcodec/libschroedingerenc.c +++ b/libavcodec/libschroedingerenc.c @@ -36,7 +36,6 @@ #include "avcodec.h" #include "internal.h" -#include "libdirac_libschro.h" #include "libschroedinger.h" #include "bytestream.h" @@ -65,7 +64,7 @@ typedef struct SchroEncoderParams { int enc_buf_size; /** queue storing encoded frames */ - DiracSchroQueue enc_frame_queue; + FFSchroQueue enc_frame_queue; /** end of sequence signalled */ int eos_signalled; @@ -80,7 +79,7 @@ typedef struct SchroEncoderParams { /** * Works out Schro-compatible chroma format. */ -static int SetSchroChromaFormat(AVCodecContext *avccontext) +static int set_chroma_format(AVCodecContext *avccontext) { int num_formats = sizeof(schro_pixel_format_map) / sizeof(schro_pixel_format_map[0]); @@ -129,7 +128,7 @@ static int libschroedinger_encode_init(AVCodecContext *avccontext) p_schro_params->format->width = avccontext->width; p_schro_params->format->height = avccontext->height; - if (SetSchroChromaFormat(avccontext) == -1) + if (set_chroma_format(avccontext) == -1) return -1; if (avccontext->color_primaries == AVCOL_PRI_BT709) { @@ -236,7 +235,7 @@ static int libschroedinger_encode_init(AVCodecContext *avccontext) schro_encoder_start(p_schro_params->encoder); /* Initialize the encoded frame queue. */ - ff_dirac_schro_queue_init(&p_schro_params->enc_frame_queue); + ff_schro_queue_init(&p_schro_params->enc_frame_queue); return 0; } @@ -259,9 +258,9 @@ static SchroFrame *libschroedinger_frame_from_data(AVCodecContext *avccontext, return in_frame; } -static void SchroedingerFreeFrame(void *data) +static void libschroedinger_free_frame(void *data) { - DiracSchroEncodedFrame *enc_frame = data; + FFSchroEncodedFrame *enc_frame = data; av_freep(&enc_frame->p_encbuf); av_free(enc_frame); @@ -273,7 +272,7 @@ static int libschroedinger_encode_frame(AVCodecContext *avccontext, AVPacket *pk int enc_size = 0; SchroEncoderParams *p_schro_params = avccontext->priv_data; SchroEncoder *encoder = p_schro_params->encoder; - struct DiracSchroEncodedFrame *p_frame_output = NULL; + struct FFSchroEncodedFrame *p_frame_output = NULL; int go = 1; SchroBuffer *enc_buf; int presentation_frame; @@ -333,7 +332,7 @@ static int libschroedinger_encode_frame(AVCodecContext *avccontext, AVPacket *pk } /* Create output frame. */ - p_frame_output = av_mallocz(sizeof(DiracSchroEncodedFrame)); + p_frame_output = av_mallocz(sizeof(FFSchroEncodedFrame)); /* Set output data. */ p_frame_output->size = p_schro_params->enc_buf_size; p_frame_output->p_encbuf = p_schro_params->enc_buf; @@ -345,8 +344,8 @@ static int libschroedinger_encode_frame(AVCodecContext *avccontext, AVPacket *pk * through 17 represesent the frame number. */ p_frame_output->frame_num = AV_RB32(enc_buf->data + 13); - ff_dirac_schro_queue_push_back(&p_schro_params->enc_frame_queue, - p_frame_output); + ff_schro_queue_push_back(&p_schro_params->enc_frame_queue, + p_frame_output); p_schro_params->enc_buf_size = 0; p_schro_params->enc_buf = NULL; @@ -373,7 +372,7 @@ static int libschroedinger_encode_frame(AVCodecContext *avccontext, AVPacket *pk p_schro_params->eos_pulled) last_frame_in_sequence = 1; - p_frame_output = ff_dirac_schro_queue_pop(&p_schro_params->enc_frame_queue); + p_frame_output = ff_schro_queue_pop(&p_schro_params->enc_frame_queue); if (!p_frame_output) return 0; @@ -410,7 +409,7 @@ static int libschroedinger_encode_frame(AVCodecContext *avccontext, AVPacket *pk error: /* free frame */ - SchroedingerFreeFrame(p_frame_output); + libschroedinger_free_frame(p_frame_output); return ret; } @@ -423,8 +422,8 @@ static int libschroedinger_encode_close(AVCodecContext *avccontext) schro_encoder_free(p_schro_params->encoder); /* Free data in the output frame queue. */ - ff_dirac_schro_queue_free(&p_schro_params->enc_frame_queue, - SchroedingerFreeFrame); + ff_schro_queue_free(&p_schro_params->enc_frame_queue, + libschroedinger_free_frame); /* Free the encoder buffer. */ diff --git a/libavcodec/mmvideo.c b/libavcodec/mmvideo.c index a7a3874a94..abba29fb75 100644 --- a/libavcodec/mmvideo.c +++ b/libavcodec/mmvideo.c @@ -85,8 +85,7 @@ static int mm_decode_pal(MmContext *s) */ static int mm_decode_intra(MmContext * s, int half_horiz, int half_vert) { - int x, y; - x=0; y=0; + int x = 0, y = 0; while (bytestream2_get_bytes_left(&s->gb) > 0) { int run_length, color; diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c index 686994d51f..482c8456af 100644 --- a/libavcodec/pthread.c +++ b/libavcodec/pthread.c @@ -1051,6 +1051,11 @@ static void validate_thread_parameters(AVCodecContext *avctx) avctx->thread_count = 1; avctx->active_thread_type = 0; } + + if (avctx->thread_count > MAX_AUTO_THREADS) + av_log(avctx, AV_LOG_WARNING, + "Application has requested %d threads. Using a thread count greater than %d is not recommended.\n", + avctx->thread_count, MAX_AUTO_THREADS); } int ff_thread_init(AVCodecContext *avctx) diff --git a/libavcodec/txd.c b/libavcodec/txd.c index 344187d7da..f931c71390 100644 --- a/libavcodec/txd.c +++ b/libavcodec/txd.c @@ -48,7 +48,6 @@ static int txd_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVFrame *picture = data; AVFrame * const p = &s->picture; unsigned int version, w, h, d3d_format, depth, stride, flags; - unsigned int av_unused mipmap_count; unsigned int y, v; uint8_t *ptr; uint32_t *pal; @@ -60,8 +59,7 @@ static int txd_decode_frame(AVCodecContext *avctx, void *data, int *data_size, w = bytestream2_get_le16(&gb); h = bytestream2_get_le16(&gb); depth = bytestream2_get_byte(&gb); - mipmap_count = bytestream2_get_byte(&gb); - bytestream2_skip(&gb, 1); + bytestream2_skip(&gb, 2); flags = bytestream2_get_byte(&gb); if (version < 8 || version > 9) { diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 71227e942a..ce60d4f684 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -390,6 +390,10 @@ static int audio_get_buffer(AVCodecContext *avctx, AVFrame *frame) frame->reordered_opaque = avctx->reordered_opaque; + frame->sample_rate = avctx->sample_rate; + frame->format = avctx->sample_fmt; + frame->channel_layout = avctx->channel_layout; + if (avctx->debug & FF_DEBUG_BUFFERS) av_log(avctx, AV_LOG_DEBUG, "default_get_buffer called on frame %p, " "internal audio buffer used\n", frame); diff --git a/libavcodec/version.h b/libavcodec/version.h index 1c142d4cb4..016cfefca3 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -27,7 +27,7 @@ */ #define LIBAVCODEC_VERSION_MAJOR 54 -#define LIBAVCODEC_VERSION_MINOR 19 +#define LIBAVCODEC_VERSION_MINOR 20 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ diff --git a/libavcodec/zerocodec.c b/libavcodec/zerocodec.c index 4944a3e486..8fd8da645f 100644 --- a/libavcodec/zerocodec.c +++ b/libavcodec/zerocodec.c @@ -65,8 +65,8 @@ static int zerocodec_decode_frame(AVCodecContext *avctx, void *data, pic->key_frame = 1; pic->pict_type = AV_PICTURE_TYPE_I; } else { - if (prev == NULL) { - av_log(avctx, AV_LOG_ERROR, "No previous frame!\n"); + if (!prev) { + av_log(avctx, AV_LOG_ERROR, "Missing reference frame!\n"); return AVERROR_INVALIDDATA; } pic->key_frame = 0; diff --git a/libavdevice/Makefile b/libavdevice/Makefile index 7f0c1d3e08..8544179472 100644 --- a/libavdevice/Makefile +++ b/libavdevice/Makefile @@ -6,7 +6,8 @@ FFLIBS-$(CONFIG_LAVFI_INDEV) += avfilter HEADERS = avdevice.h -OBJS = alldevices.o avdevice.o +OBJS = alldevices.o \ + avdevice.o \ # input/output devices OBJS-$(CONFIG_ALSA_INDEV) += alsa-audio-common.o \ diff --git a/libavfilter/Makefile b/libavfilter/Makefile index e7ed1a5250..7da07eb76a 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -11,7 +11,14 @@ FFLIBS-$(CONFIG_PAN_FILTER) += swresample FFLIBS-$(CONFIG_REMOVELOGO_FILTER) += avformat avcodec FFLIBS-$(CONFIG_MP_FILTER) += avcodec postproc -HEADERS = asrc_abuffer.h avcodec.h avfilter.h avfiltergraph.h buffersink.h buffersrc.h version.h vsrc_buffer.h +HEADERS = asrc_abuffer.h \ + avcodec.h \ + avfilter.h \ + avfiltergraph.h \ + buffersink.h \ + buffersrc.h \ + version.h \ + vsrc_buffer.h \ OBJS = allfilters.o \ avfilter.o \ @@ -171,4 +178,5 @@ OBJS-$(CONFIG_MP_FILTER) += libmpcodecs/pullup.o TESTPROGS = drawutils formats -TOOLS = graph2dot lavfi-showfiltfmts +TOOLS = graph2dot \ + lavfi-showfiltfmts \ diff --git a/libavfilter/avcodec.c b/libavfilter/avcodec.c index 850e21a546..a63c2a3c95 100644 --- a/libavfilter/avcodec.c +++ b/libavfilter/avcodec.c @@ -41,10 +41,11 @@ int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src) dst->video->pict_type = src->pict_type; break; case AVMEDIA_TYPE_AUDIO: - dst->audio->sample_rate = av_frame_get_sample_rate(src); + dst->audio->sample_rate = src->sample_rate; + dst->audio->channel_layout = src->channel_layout; break; default: - return AVERROR(ENOSYS); + return AVERROR(EINVAL); } return 0; diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index d71ffdc620..99b97dfc5c 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -901,3 +901,15 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque return ret; } +void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src) +{ + // copy common properties + dst->pts = src->pts; + dst->pos = src->pos; + + switch (src->type) { + case AVMEDIA_TYPE_VIDEO: *dst->video = *src->video; break; + case AVMEDIA_TYPE_AUDIO: *dst->audio = *src->audio; break; + default: break; + } +} diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index ae296cbef3..c526df4a9f 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -155,18 +155,7 @@ typedef struct AVFilterBufferRef { /** * Copy properties of src to dst, without copying the actual data */ -static inline void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src) -{ - // copy common properties - dst->pts = src->pts; - dst->pos = src->pos; - - switch (src->type) { - case AVMEDIA_TYPE_VIDEO: *dst->video = *src->video; break; - case AVMEDIA_TYPE_AUDIO: *dst->audio = *src->audio; break; - default: break; - } -} +void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src); /** * Add a new reference to a buffer. diff --git a/libavfilter/formats.c b/libavfilter/formats.c index c52c79dd26..569178fca8 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -47,7 +47,8 @@ AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b) AVFilterFormats *ret; unsigned i, j, k = 0; - if (a == b) return a; + if (a == b) + return a; ret = av_mallocz(sizeof(*ret)); diff --git a/libavfilter/version.h b/libavfilter/version.h index c9da0c57f7..1aee0374fe 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -30,7 +30,7 @@ #define LIBAVFILTER_VERSION_MAJOR 2 #define LIBAVFILTER_VERSION_MINOR 72 -#define LIBAVFILTER_VERSION_MICRO 104 +#define LIBAVFILTER_VERSION_MICRO 105 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ LIBAVFILTER_VERSION_MINOR, \ diff --git a/libavformat/Makefile b/libavformat/Makefile index c034296a95..0a3beaa3ca 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -3,7 +3,9 @@ include $(SUBDIR)../config.mak NAME = avformat FFLIBS = avcodec avutil -HEADERS = avformat.h avio.h version.h +HEADERS = avformat.h \ + avio.h \ + version.h \ OBJS = allformats.o \ avio.o \ @@ -378,4 +380,8 @@ OBJS-$(CONFIG_UDP_PROTOCOL) += udp.o SKIPHEADERS-$(CONFIG_NETWORK) += network.h rtsp.h TESTPROGS = seek -TOOLS = aviocat ismindex pktdumper probetest + +TOOLS = aviocat \ + ismindex \ + pktdumper \ + probetest \ diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 730ce12f35..ce9d70a8ad 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -856,7 +856,7 @@ typedef struct AVFormatContext { */ void *priv_data; - /* + /** * I/O context. * * decoding: either set by the user before avformat_open_input() (then diff --git a/libavresample/Makefile b/libavresample/Makefile index ce3fe81953..c0c20a900a 100644 --- a/libavresample/Makefile +++ b/libavresample/Makefile @@ -2,7 +2,7 @@ NAME = avresample FFLIBS = avutil HEADERS = avresample.h \ - version.h + version.h \ OBJS = audio_convert.o \ audio_data.o \ @@ -10,6 +10,6 @@ OBJS = audio_convert.o \ audio_mix_matrix.o \ options.o \ resample.o \ - utils.o + utils.o \ TESTPROGS = avresample diff --git a/libavresample/x86/Makefile b/libavresample/x86/Makefile index 63697faee7..65bed899ba 100644 --- a/libavresample/x86/Makefile +++ b/libavresample/x86/Makefile @@ -1,5 +1,5 @@ OBJS += x86/audio_convert_init.o \ - x86/audio_mix_init.o + x86/audio_mix_init.o \ YASM-OBJS += x86/audio_convert.o \ - x86/audio_mix.o + x86/audio_mix.o \ diff --git a/libavutil/Makefile b/libavutil/Makefile index 83e6c07605..a4498313a9 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -42,6 +42,11 @@ HEADERS = adler32.h \ timecode.h \ timestamp.h \ +ARCH_HEADERS = bswap.h \ + intmath.h \ + intreadwrite.h \ + timer.h \ + BUILT_HEADERS = avconfig.h OBJS = adler32.o \ @@ -81,12 +86,30 @@ OBJS = adler32.o \ tree.o \ utils.o \ -TESTPROGS = adler32 aes avstring base64 bprint cpu crc des eval file fifo \ - lfg lls md5 opt pca parseutils random_seed rational sha tree +TESTPROGS = adler32 \ + aes \ + avstring \ + base64 \ + bprint \ + cpu \ + crc \ + des \ + eval \ + file \ + fifo \ + lfg \ + lls \ + md5 \ + opt \ + pca \ + parseutils \ + random_seed \ + rational \ + sha \ + tree \ + TESTPROGS-$(HAVE_LZO1X_999_COMPRESS) += lzo TOOLS = ffeval -ARCH_HEADERS = bswap.h intmath.h intreadwrite.h timer.h - $(SUBDIR)lzo-test$(EXESUF): ELIBS = -llzo2 diff --git a/libavutil/arm/Makefile b/libavutil/arm/Makefile index 246f73a8ac..e600383b9c 100644 --- a/libavutil/arm/Makefile +++ b/libavutil/arm/Makefile @@ -1 +1 @@ -OBJS += arm/cpu.o +OBJS += arm/cpu.o \ diff --git a/libswscale/Makefile b/libswscale/Makefile index a77d51cee0..488a91d17f 100644 --- a/libswscale/Makefile +++ b/libswscale/Makefile @@ -14,4 +14,5 @@ OBJS = input.o \ utils.o \ yuv2rgb.o \ -TESTPROGS = colorspace swscale +TESTPROGS = colorspace \ + swscale \ |