* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avformat.h"
+#include "allformats.h"
#undef NDEBUG
#include <assert.h>
* Various utility functions for using ffmpeg library.
*/
+static void av_frac_init(AVFrac *f, int64_t val, int64_t num, int64_t den);
+static void av_frac_add(AVFrac *f, int64_t incr);
+static void av_frac_set(AVFrac *f, int64_t val);
+
/** head of registered input format linked list. */
AVInputFormat *first_iformat = NULL;
/** head of registered output format linked list. */
int score_max, score;
/* specific test for image sequences */
+#ifdef CONFIG_IMAGE2_MUXER
if (!short_name && filename &&
filename_number_test(filename) >= 0 &&
av_guess_image2_codec(filename) != CODEC_ID_NONE) {
return guess_format("image2", NULL, NULL);
}
+#endif
if (!short_name && filename &&
filename_number_test(filename) >= 0 &&
guess_image_format(filename)) {
if(type == CODEC_TYPE_VIDEO){
enum CodecID codec_id= CODEC_ID_NONE;
+#ifdef CONFIG_IMAGE2_MUXER
if(!strcmp(fmt->name, "image2") || !strcmp(fmt->name, "image2pipe")){
codec_id= av_guess_image2_codec(filename);
}
+#endif
if(codec_id == CODEC_ID_NONE)
codec_id= fmt->video_codec;
return codec_id;
}
}
-void fifo_write(FifoBuffer *f, uint8_t *buf, int size, uint8_t **wptr_ptr)
+void fifo_write(FifoBuffer *f, const uint8_t *buf, int size, uint8_t **wptr_ptr)
{
int len;
uint8_t *wptr;
/* XXX: suppress this hack for redirectors */
#ifdef CONFIG_NETWORK
- if (fmt == &redir_demux) {
+ if (fmt == &redir_demuxer) {
err = redir_open(ic_ptr, pb);
url_fclose(pb);
return err;
int frame_size;
if (enc->frame_size <= 1) {
- /* specific hack for pcm codecs because no frame size is
- provided */
- switch(enc->codec_id) {
- case CODEC_ID_PCM_S32LE:
- case CODEC_ID_PCM_S32BE:
- case CODEC_ID_PCM_U32LE:
- case CODEC_ID_PCM_U32BE:
- if (enc->channels == 0)
- return -1;
- frame_size = size / (4 * enc->channels);
- break;
- case CODEC_ID_PCM_S24LE:
- case CODEC_ID_PCM_S24BE:
- case CODEC_ID_PCM_U24LE:
- case CODEC_ID_PCM_U24BE:
- case CODEC_ID_PCM_S24DAUD:
- if (enc->channels == 0)
- return -1;
- frame_size = size / (3 * enc->channels);
- break;
- case CODEC_ID_PCM_S16LE:
- case CODEC_ID_PCM_S16BE:
- case CODEC_ID_PCM_U16LE:
- case CODEC_ID_PCM_U16BE:
- if (enc->channels == 0)
- return -1;
- frame_size = size / (2 * enc->channels);
- break;
- case CODEC_ID_PCM_S8:
- case CODEC_ID_PCM_U8:
- case CODEC_ID_PCM_MULAW:
- case CODEC_ID_PCM_ALAW:
+ int bits_per_sample = av_get_bits_per_sample(enc->codec_id);
+
+ if (bits_per_sample) {
if (enc->channels == 0)
return -1;
- frame_size = size / (enc->channels);
- break;
- default:
+ frame_size = (size << 3) / (bits_per_sample * enc->channels);
+ } else {
/* used for example by ADPCM codecs */
if (enc->bit_rate == 0)
return -1;
frame_size = (size * 8 * enc->sample_rate) / enc->bit_rate;
- break;
}
} else {
frame_size = enc->frame_size;
}
ic->file_size = file_size;
- if ((ic->iformat == &mpegps_demux || ic->iformat == &mpegts_demux) && file_size && !ic->pb.is_streamed) {
+ if ((!strcmp(ic->iformat->name, "mpeg") ||
+ !strcmp(ic->iformat->name, "mpegts")) &&
+ file_size && !ic->pb.is_streamed) {
/* get accurate estimate from the PTSes */
av_estimate_timings_from_pts(ic);
} else if (av_has_timings(ic)) {
#define MAX_READ_SIZE 5000000
/* maximum duration until we stop analysing the stream */
-#define MAX_STREAM_DURATION ((int)(AV_TIME_BASE * 2.0))
+#define MAX_STREAM_DURATION ((int)(AV_TIME_BASE * 3.0))
/**
* Read the beginning of a media file to get stream information. This
char buf[256];
avcodec_string(buf, sizeof(buf), st->codec, 0);
av_log(ic, AV_LOG_INFO, "Could not find codec parameters (%s)\n", buf);
- break;
+ } else {
+ ret = 0;
}
}
- if (i == ic->nb_streams)
- ret = 0;
break;
}
int i= st->parser->parser->split(st->codec, pkt->data, pkt->size);
if(i){
st->codec->extradata_size= i;
- st->codec->extradata= av_malloc(st->codec->extradata_size);
+ st->codec->extradata= av_malloc(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
memcpy(st->codec->extradata, pkt->data, st->codec->extradata_size);
+ memset(st->codec->extradata + i, 0, FF_INPUT_BUFFER_PADDING_SIZE);
}
}
* @param num must be >= 0
* @param den must be >= 1
*/
-void av_frac_init(AVFrac *f, int64_t val, int64_t num, int64_t den)
+static void av_frac_init(AVFrac *f, int64_t val, int64_t num, int64_t den)
{
num += (den >> 1);
if (num >= den) {
/**
* Set f to (val + 0.5).
*/
-void av_frac_set(AVFrac *f, int64_t val)
+static void av_frac_set(AVFrac *f, int64_t val)
{
f->val = val;
f->num = f->den >> 1;
* @param f fractional number
* @param incr increment, can be positive or negative
*/
-void av_frac_add(AVFrac *f, int64_t incr)
+static void av_frac_add(AVFrac *f, int64_t incr)
{
int64_t num, den;