Merge commit '1b891d17c531e8a63c2974aab4bf997ce70746f3'
authorMichael Niedermayer <michaelni@gmx.at>
Fri, 26 Oct 2012 12:07:04 +0000 (14:07 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 26 Oct 2012 12:24:57 +0000 (14:24 +0200)
* commit '1b891d17c531e8a63c2974aab4bf997ce70746f3':
  avconv: fix bitrate report when writing to /dev/null
  avfilter: fix graphparser memleaks on error paths
  rawdec: remove ff_raw_read_header
  pcmdec: remove dependency from rawdec
  g722: refactor out of rawdec.c
  rawvideo: use a specific read_header

Conflicts:
ffmpeg.c
libavformat/Makefile
libavformat/rawdec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
ffmpeg.c
libavfilter/graphparser.c
libavformat/Makefile
libavformat/g722.c
libavformat/pcmdec.c
libavformat/rawdec.c
libavformat/rawdec.h
libavformat/rawvideodec.c

diff --cc ffmpeg.c
Simple merge
Simple merge
@@@ -112,11 -101,9 +112,11 @@@ OBJS-$(CONFIG_GIF_MUXER
  OBJS-$(CONFIG_GSM_DEMUXER)               += gsmdec.o
  OBJS-$(CONFIG_GXF_DEMUXER)               += gxf.o
  OBJS-$(CONFIG_GXF_MUXER)                 += gxfenc.o audiointerleave.o
- OBJS-$(CONFIG_G722_DEMUXER)              += rawdec.o
+ OBJS-$(CONFIG_G722_DEMUXER)              += g722.o rawdec.o
  OBJS-$(CONFIG_G722_MUXER)                += rawenc.o
  OBJS-$(CONFIG_G723_1_DEMUXER)            += g723_1.o
 +OBJS-$(CONFIG_G723_1_MUXER)              += rawenc.o
 +OBJS-$(CONFIG_G729_DEMUXER)              += g729dec.o
  OBJS-$(CONFIG_H261_DEMUXER)              += h261dec.o rawdec.o
  OBJS-$(CONFIG_H261_MUXER)                += rawenc.o
  OBJS-$(CONFIG_H263_DEMUXER)              += h263dec.o rawdec.o
@@@ -219,54 -195,52 +219,54 @@@ OBJS-$(CONFIG_OGG_MUXER
                                              vorbiscomment.o
  OBJS-$(CONFIG_OMA_DEMUXER)               += omadec.o pcm.o oma.o
  OBJS-$(CONFIG_OMA_MUXER)                 += omaenc.o rawenc.o oma.o id3v2enc.o
- OBJS-$(CONFIG_PCM_ALAW_DEMUXER)          += pcmdec.o pcm.o rawdec.o
 +OBJS-$(CONFIG_PAF_DEMUXER)               += paf.o
+ OBJS-$(CONFIG_PCM_ALAW_DEMUXER)          += pcmdec.o pcm.o
  OBJS-$(CONFIG_PCM_ALAW_MUXER)            += pcmenc.o rawenc.o
- OBJS-$(CONFIG_PCM_F32BE_DEMUXER)         += pcmdec.o pcm.o rawdec.o
+ OBJS-$(CONFIG_PCM_F32BE_DEMUXER)         += pcmdec.o pcm.o
  OBJS-$(CONFIG_PCM_F32BE_MUXER)           += pcmenc.o rawenc.o
- OBJS-$(CONFIG_PCM_F32LE_DEMUXER)         += pcmdec.o pcm.o rawdec.o
+ OBJS-$(CONFIG_PCM_F32LE_DEMUXER)         += pcmdec.o pcm.o
  OBJS-$(CONFIG_PCM_F32LE_MUXER)           += pcmenc.o rawenc.o
- OBJS-$(CONFIG_PCM_F64BE_DEMUXER)         += pcmdec.o pcm.o rawdec.o
+ OBJS-$(CONFIG_PCM_F64BE_DEMUXER)         += pcmdec.o pcm.o
  OBJS-$(CONFIG_PCM_F64BE_MUXER)           += pcmenc.o rawenc.o
- OBJS-$(CONFIG_PCM_F64LE_DEMUXER)         += pcmdec.o pcm.o rawdec.o
+ OBJS-$(CONFIG_PCM_F64LE_DEMUXER)         += pcmdec.o pcm.o
  OBJS-$(CONFIG_PCM_F64LE_MUXER)           += pcmenc.o rawenc.o
- OBJS-$(CONFIG_PCM_MULAW_DEMUXER)         += pcmdec.o pcm.o rawdec.o
+ OBJS-$(CONFIG_PCM_MULAW_DEMUXER)         += pcmdec.o pcm.o
  OBJS-$(CONFIG_PCM_MULAW_MUXER)           += pcmenc.o rawenc.o
- OBJS-$(CONFIG_PCM_S16BE_DEMUXER)         += pcmdec.o pcm.o rawdec.o
+ OBJS-$(CONFIG_PCM_S16BE_DEMUXER)         += pcmdec.o pcm.o
  OBJS-$(CONFIG_PCM_S16BE_MUXER)           += pcmenc.o rawenc.o
- OBJS-$(CONFIG_PCM_S16LE_DEMUXER)         += pcmdec.o pcm.o rawdec.o
+ OBJS-$(CONFIG_PCM_S16LE_DEMUXER)         += pcmdec.o pcm.o
  OBJS-$(CONFIG_PCM_S16LE_MUXER)           += pcmenc.o rawenc.o
- OBJS-$(CONFIG_PCM_S24BE_DEMUXER)         += pcmdec.o pcm.o rawdec.o
+ OBJS-$(CONFIG_PCM_S24BE_DEMUXER)         += pcmdec.o pcm.o
  OBJS-$(CONFIG_PCM_S24BE_MUXER)           += pcmenc.o rawenc.o
- OBJS-$(CONFIG_PCM_S24LE_DEMUXER)         += pcmdec.o pcm.o rawdec.o
+ OBJS-$(CONFIG_PCM_S24LE_DEMUXER)         += pcmdec.o pcm.o
  OBJS-$(CONFIG_PCM_S24LE_MUXER)           += pcmenc.o rawenc.o
- OBJS-$(CONFIG_PCM_S32BE_DEMUXER)         += pcmdec.o pcm.o rawdec.o
+ OBJS-$(CONFIG_PCM_S32BE_DEMUXER)         += pcmdec.o pcm.o
  OBJS-$(CONFIG_PCM_S32BE_MUXER)           += pcmenc.o rawenc.o
- OBJS-$(CONFIG_PCM_S32LE_DEMUXER)         += pcmdec.o pcm.o rawdec.o
+ OBJS-$(CONFIG_PCM_S32LE_DEMUXER)         += pcmdec.o pcm.o
  OBJS-$(CONFIG_PCM_S32LE_MUXER)           += pcmenc.o rawenc.o
- OBJS-$(CONFIG_PCM_S8_DEMUXER)            += pcmdec.o pcm.o rawdec.o
+ OBJS-$(CONFIG_PCM_S8_DEMUXER)            += pcmdec.o pcm.o
  OBJS-$(CONFIG_PCM_S8_MUXER)              += pcmenc.o rawenc.o
- OBJS-$(CONFIG_PCM_U16BE_DEMUXER)         += pcmdec.o pcm.o rawdec.o
+ OBJS-$(CONFIG_PCM_U16BE_DEMUXER)         += pcmdec.o pcm.o
  OBJS-$(CONFIG_PCM_U16BE_MUXER)           += pcmenc.o rawenc.o
- OBJS-$(CONFIG_PCM_U16LE_DEMUXER)         += pcmdec.o pcm.o rawdec.o
+ OBJS-$(CONFIG_PCM_U16LE_DEMUXER)         += pcmdec.o pcm.o
  OBJS-$(CONFIG_PCM_U16LE_MUXER)           += pcmenc.o rawenc.o
- OBJS-$(CONFIG_PCM_U24BE_DEMUXER)         += pcmdec.o pcm.o rawdec.o
+ OBJS-$(CONFIG_PCM_U24BE_DEMUXER)         += pcmdec.o pcm.o
  OBJS-$(CONFIG_PCM_U24BE_MUXER)           += pcmenc.o rawenc.o
- OBJS-$(CONFIG_PCM_U24LE_DEMUXER)         += pcmdec.o pcm.o rawdec.o
+ OBJS-$(CONFIG_PCM_U24LE_DEMUXER)         += pcmdec.o pcm.o
  OBJS-$(CONFIG_PCM_U24LE_MUXER)           += pcmenc.o rawenc.o
- OBJS-$(CONFIG_PCM_U32BE_DEMUXER)         += pcmdec.o pcm.o rawdec.o
+ OBJS-$(CONFIG_PCM_U32BE_DEMUXER)         += pcmdec.o pcm.o
  OBJS-$(CONFIG_PCM_U32BE_MUXER)           += pcmenc.o rawenc.o
- OBJS-$(CONFIG_PCM_U32LE_DEMUXER)         += pcmdec.o pcm.o rawdec.o
+ OBJS-$(CONFIG_PCM_U32LE_DEMUXER)         += pcmdec.o pcm.o
  OBJS-$(CONFIG_PCM_U32LE_MUXER)           += pcmenc.o rawenc.o
- OBJS-$(CONFIG_PCM_U8_DEMUXER)            += pcmdec.o pcm.o rawdec.o
+ OBJS-$(CONFIG_PCM_U8_DEMUXER)            += pcmdec.o pcm.o
  OBJS-$(CONFIG_PCM_U8_MUXER)              += pcmenc.o rawenc.o
  OBJS-$(CONFIG_PMP_DEMUXER)               += pmpdec.o
  OBJS-$(CONFIG_PVA_DEMUXER)               += pva.o
  OBJS-$(CONFIG_QCP_DEMUXER)               += qcp.o
  OBJS-$(CONFIG_R3D_DEMUXER)               += r3d.o
- OBJS-$(CONFIG_RAWVIDEO_DEMUXER)          += rawvideodec.o rawdec.o
+ OBJS-$(CONFIG_RAWVIDEO_DEMUXER)          += rawvideodec.o
  OBJS-$(CONFIG_RAWVIDEO_MUXER)            += rawenc.o
 +OBJS-$(CONFIG_REALTEXT_DEMUXER)          += realtextdec.o
  OBJS-$(CONFIG_RL2_DEMUXER)               += rl2.o
  OBJS-$(CONFIG_RM_DEMUXER)                += rmdec.o rm.o rmsipr.o
  OBJS-$(CONFIG_RM_MUXER)                  += rmenc.o rm.o
index 0000000,8052939..1a87c7d
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,56 +1,57 @@@
 - * This file is part of Libav.
+ /*
+  * g722 raw demuxer
+  * Copyright (c) 2010 Martin Storsjo
+  *
 - * Libav is free software; you can redistribute it and/or
++ * This file is part of FFmpeg.
+  *
 - * Libav is distributed in the hope that it will be useful,
++ * 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.
+  *
 - * License along with Libav; if not, write to the Free Software
++ * 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
 -    assert(st->codec->bits_per_coded_sample > 0);
++ * License along with FFmpeg; if not, write to the Free Software
+  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+  */
++#include "libavutil/avassert.h"
+ #include "avformat.h"
+ #include "internal.h"
+ #include "rawdec.h"
+ static int g722_read_header(AVFormatContext *s)
+ {
+     AVStream *st;
+     st = avformat_new_stream(s, NULL);
+     if (!st)
+         return AVERROR(ENOMEM);
+     st->codec->codec_type  = AVMEDIA_TYPE_AUDIO;
+     st->codec->codec_id    = AV_CODEC_ID_ADPCM_G722;
+     st->codec->sample_rate = 16000;
+     st->codec->channels    = 1;
+     st->codec->bits_per_coded_sample =
+         av_get_bits_per_sample(st->codec->codec_id);
++    av_assert0(st->codec->bits_per_coded_sample > 0);
+     avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+     return 0;
+ }
+ AVInputFormat ff_g722_demuxer = {
+     .name           = "g722",
+     .long_name      = NULL_IF_CONFIG_SMALL("raw G.722"),
+     .read_header    = g722_read_header,
+     .read_packet    = ff_raw_read_partial_packet,
+     .flags          = AVFMT_GENERIC_INDEX,
+     .extensions     = "g722,722",
+     .raw_codec_id   = AV_CODEC_ID_ADPCM_G722,
+ };
  
  #define RAW_SAMPLES     1024
  
 -    assert(st->codec->bits_per_coded_sample > 0);
+ typedef struct RawAudioDemuxerContext {
+     AVClass *class;
+     int sample_rate;
+     int channels;
+ } RawAudioDemuxerContext;
+ static int raw_read_header(AVFormatContext *s)
+ {
+     RawAudioDemuxerContext *s1 = s->priv_data;
+     AVStream *st;
+     st = avformat_new_stream(s, NULL);
+     if (!st)
+         return AVERROR(ENOMEM);
+     st->codec->codec_type  = AVMEDIA_TYPE_AUDIO;
+     st->codec->codec_id    = s->iformat->raw_codec_id;
+     st->codec->sample_rate = s1->sample_rate;
+     st->codec->channels    = s1->channels;
+     st->codec->bits_per_coded_sample =
+         av_get_bits_per_sample(st->codec->codec_id);
++    av_assert0(st->codec->bits_per_coded_sample > 0);
+     st->codec->block_align =
+         st->codec->bits_per_coded_sample * st->codec->channels / 8;
+     avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+     return 0;
+ }
  static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
  {
      int ret, size, bps;
@@@ -51,8 -82,8 +84,8 @@@
  }
  
  static const AVOption pcm_options[] = {
--    { "sample_rate", "", offsetof(RawAudioDemuxerContext, sample_rate), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
--    { "channels",    "", offsetof(RawAudioDemuxerContext, channels),    AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
++    { "sample_rate", "", offsetof(RawAudioDemuxerContext, sample_rate), AV_OPT_TYPE_INT, {.i64 = 44100}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
++    { "channels",    "", offsetof(RawAudioDemuxerContext, channels),    AV_OPT_TYPE_INT, {.i64 = 1}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
      { NULL },
  };
  
  #include "libavutil/opt.h"
  #include "libavutil/parseutils.h"
  #include "libavutil/pixdesc.h"
 +#include "libavutil/avassert.h"
  
- /* raw input */
- int ff_raw_read_header(AVFormatContext *s)
- {
-     AVStream *st;
-     enum AVCodecID id;
-     st = avformat_new_stream(s, NULL);
-     if (!st)
-         return AVERROR(ENOMEM);
-         id = s->iformat->raw_codec_id;
-         if (id == AV_CODEC_ID_RAWVIDEO) {
-             st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-         } else {
-             st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
-         }
-         st->codec->codec_id = id;
-         switch(st->codec->codec_type) {
-         case AVMEDIA_TYPE_AUDIO: {
-             RawAudioDemuxerContext *s1 = s->priv_data;
-             st->codec->channels = 1;
-             if (id == AV_CODEC_ID_ADPCM_G722)
-                 st->codec->sample_rate = 16000;
-             if (s1 && s1->sample_rate)
-                 st->codec->sample_rate = s1->sample_rate;
-             if (st->codec->sample_rate <= 0) {
-                 av_log(s, AV_LOG_WARNING, "Invalid sample rate %d specified using default of 44100\n",
-                        st->codec->sample_rate);
-                 st->codec->sample_rate= 44100;
-             }
-             if (s1 && s1->channels)
-                 st->codec->channels    = s1->channels;
-             st->codec->bits_per_coded_sample = av_get_bits_per_sample(st->codec->codec_id);
-             av_assert0(st->codec->bits_per_coded_sample > 0);
-             st->codec->block_align = st->codec->bits_per_coded_sample*st->codec->channels/8;
-             avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
-             break;
-             }
-         case AVMEDIA_TYPE_VIDEO: {
-             FFRawVideoDemuxerContext *s1 = s->priv_data;
-             int width = 0, height = 0, ret = 0;
-             enum AVPixelFormat pix_fmt;
-             AVRational framerate;
-             if (s1->video_size && (ret = av_parse_video_size(&width, &height, s1->video_size)) < 0) {
-                 av_log(s, AV_LOG_ERROR, "Couldn't parse video size.\n");
-                 goto fail;
-             }
-             if ((pix_fmt = av_get_pix_fmt(s1->pixel_format)) == AV_PIX_FMT_NONE) {
-                 av_log(s, AV_LOG_ERROR, "No such pixel format: %s.\n", s1->pixel_format);
-                 ret = AVERROR(EINVAL);
-                 goto fail;
-             }
-             if ((ret = av_parse_video_rate(&framerate, s1->framerate)) < 0) {
-                 av_log(s, AV_LOG_ERROR, "Could not parse framerate: %s.\n", s1->framerate);
-                 goto fail;
-             }
-             avpriv_set_pts_info(st, 64, framerate.den, framerate.num);
-             st->codec->width  = width;
-             st->codec->height = height;
-             st->codec->pix_fmt = pix_fmt;
- fail:
-             return ret;
-             }
-         default:
-             return -1;
-         }
-     return 0;
- }
  #define RAW_PACKET_SIZE 1024
  
  int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt)
Simple merge
Simple merge