* release/0.8: (31 commits) svq1dec: call avcodec_set_dimensions() after dimensions changed. Fixes NGS00148 vp3dec: Check coefficient index in vp3_dequant() Fixes NGS00145 qdm2dec: fix buffer overflow. Fixes NGS00144 h264: Fix invalid interlaced progressive MB combinations for direct mode prediction. Fixes Ticket312 mpegvideo: dont use ff_mspel_motion() for vc1 Fixes Ticket655 imgutils: Fix illegal read. ac3probe: Detect Sonic Foundry Soft Encode AC3 as raw AC3. Our ac3 code chain can handle it fine. More ideal would be to write a demuxer that actually extracts what can be from the additional headers and uses it for whatever it can be used for. mjpeg: support mpo Fixes stereoscopic_photo.mpo Add a version bump and APIchanges entry for avcodec_open2 and avformat_find_stream_info. lavf: fix multiplication overflow in avformat_find_stream_info() lavf: fix invalid reads in avformat_find_stream_info() lavf: add avformat_find_stream_info() lavc: fix parentheses placement in avcodec_open2(). lavc: introduce avcodec_open2() as a replacement for avcodec_open(). rawdec: use a default sample rate if none is specified. Fixes "ffmpeg -f s16le -i /dev/zero" rawdec: add check on sample_rate qdm2dec: check remaining input bits in the mainloop of qdm2_fft_decode_tones() This is neccessary but likely not sufficient to prevent out of array reads. cinepak: check strip_size wma: Check channel number before init. Fixes Ticket240 Do not try to read 16bit gray png files with alpha channel. ... Conflicts: libavcodec/version.h libavformat/version.h Merged-by: Michael Niedermayer <michaelni@gmx.at>tags/n0.7.8
| @@ -13,6 +13,7 @@ libavutil: 2011-04-18 | |||
| API changes, most recent first: | |||
| 2011-06-19 - xxxxxxx - lavfi 2.23.0 - avfilter.h | |||
| Add layout negotiation fields and helper functions. | |||
| @@ -43,6 +44,12 @@ API changes, most recent first: | |||
| 2011-06-12 - xxxxxxx - lavfi 2.16.0 - avfilter_graph_parse() | |||
| Change avfilter_graph_parse() signature. | |||
| 2011-07-10 - xxxxxxx - lavf 53.3.0 | |||
| Add avformat_find_stream_info(), deprecate av_find_stream_info(). | |||
| 2011-07-10 - xxxxxxx - lavc 53.6.0 | |||
| Add avcodec_open2(), deprecate avcodec_open(). | |||
| 2011-06-xx - xxxxxxx - lavf 53.2.0 - avformat.h | |||
| Add avformat_open_input and avformat_write_header(). | |||
| Deprecate av_open_input_stream, av_open_input_file, | |||
| @@ -2135,7 +2135,12 @@ static int stream_component_open(VideoState *is, int stream_index) | |||
| avctx->workaround_bugs = workaround_bugs; | |||
| avctx->lowres = lowres; | |||
| if(lowres) avctx->flags |= CODEC_FLAG_EMU_EDGE; | |||
| if(avctx->lowres > codec->max_lowres){ | |||
| av_log(avctx, AV_LOG_WARNING, "The maximum value for lowres supported by the decoder is %d\n", | |||
| codec->max_lowres); | |||
| avctx->lowres= codec->max_lowres; | |||
| } | |||
| if(avctx->lowres) avctx->flags |= CODEC_FLAG_EMU_EDGE; | |||
| avctx->idct_algo= idct; | |||
| if(fast) avctx->flags2 |= CODEC_FLAG2_FAST; | |||
| avctx->skip_frame= skip_frame; | |||
| @@ -30,6 +30,7 @@ | |||
| #include "libavutil/samplefmt.h" | |||
| #include "libavutil/avutil.h" | |||
| #include "libavutil/cpu.h" | |||
| #include "libavutil/dict.h" | |||
| #include "libavcodec/version.h" | |||
| @@ -3784,6 +3785,7 @@ int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, v | |||
| int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count); | |||
| //FIXME func typedef | |||
| #if FF_API_AVCODEC_OPEN | |||
| /** | |||
| * Initialize the AVCodecContext to use the given AVCodec. Prior to using this | |||
| * function the context has to be allocated. | |||
| @@ -3810,8 +3812,44 @@ int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, | |||
| * @param codec The codec to use within the context. | |||
| * @return zero on success, a negative value on error | |||
| * @see avcodec_alloc_context, avcodec_find_decoder, avcodec_find_encoder, avcodec_close | |||
| * | |||
| * @deprecated use avcodec_open2 | |||
| */ | |||
| int avcodec_open(AVCodecContext *avctx, AVCodec *codec); | |||
| #endif | |||
| /** | |||
| * Initialize the AVCodecContext to use the given AVCodec. Prior to using this | |||
| * function the context has to be allocated with avcodec_alloc_context(). | |||
| * | |||
| * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(), | |||
| * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for | |||
| * retrieving a codec. | |||
| * | |||
| * @warning This function is not thread safe! | |||
| * | |||
| * @code | |||
| * avcodec_register_all(); | |||
| * av_dict_set(&opts, "b", "2.5M", 0); | |||
| * codec = avcodec_find_decoder(CODEC_ID_H264); | |||
| * if (!codec) | |||
| * exit(1); | |||
| * | |||
| * context = avcodec_alloc_context(); | |||
| * | |||
| * if (avcodec_open(context, codec, opts) < 0) | |||
| * exit(1); | |||
| * @endcode | |||
| * | |||
| * @param avctx The context to initialize. | |||
| * @param options A dictionary filled with AVCodecContext and codec-private options. | |||
| * On return this object will be filled with options that were not found. | |||
| * | |||
| * @return zero on success, a negative value on error | |||
| * @see avcodec_alloc_context3(), avcodec_find_decoder(), avcodec_find_encoder(), | |||
| * av_dict_set(), av_opt_find(). | |||
| */ | |||
| int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options); | |||
| #if FF_API_AUDIO_OLD | |||
| /** | |||
| @@ -365,6 +365,8 @@ static int cinepak_decode (CinepakContext *s) | |||
| s->strips[i].x2 = s->avctx->width; | |||
| strip_size = AV_RB24 (&s->data[1]) - 12; | |||
| if(strip_size < 0) | |||
| return -1; | |||
| s->data += 12; | |||
| strip_size = ((s->data + strip_size) > eod) ? (eod - s->data) : strip_size; | |||
| @@ -1079,7 +1079,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) | |||
| q->subpacket[s].subbands = bytestream_get_be16(&edata_ptr); | |||
| extradata_size -= 8; | |||
| } | |||
| if (avctx->extradata_size >= 8){ | |||
| if (extradata_size >= 8){ | |||
| bytestream_get_be32(&edata_ptr); //Unknown unused | |||
| q->subpacket[s].js_subband_start = bytestream_get_be16(&edata_ptr); | |||
| q->subpacket[s].js_vlc_bits = bytestream_get_be16(&edata_ptr); | |||
| @@ -253,6 +253,10 @@ static void pred_spatial_direct_motion(H264Context * const h, int *mb_type){ | |||
| mb_type_col[1] = h->ref_list[1][0].mb_type[mb_xy + s->mb_stride]; | |||
| b8_stride = 2+4*s->mb_stride; | |||
| b4_stride *= 6; | |||
| if(IS_INTERLACED(mb_type_col[0]) != IS_INTERLACED(mb_type_col[1])){ | |||
| mb_type_col[0] &= ~MB_TYPE_INTERLACED; | |||
| mb_type_col[1] &= ~MB_TYPE_INTERLACED; | |||
| } | |||
| sub_mb_type |= MB_TYPE_16x16|MB_TYPE_DIRECT2; /* B_SUB_8x8 */ | |||
| if( (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA) | |||
| @@ -725,7 +725,7 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s, | |||
| 0, 0, 0, | |||
| ref_picture, pix_op, qpix_op, | |||
| s->mv[dir][0][0], s->mv[dir][0][1], 16); | |||
| }else if(!is_mpeg12 && (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) && s->mspel){ | |||
| }else if(!is_mpeg12 && (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) && s->mspel && s->codec_id == CODEC_ID_WMV2){ | |||
| ff_mspel_motion(s, dest_y, dest_cb, dest_cr, | |||
| ref_picture, pix_op, | |||
| s->mv[dir][0][0], s->mv[dir][0][1], 16); | |||
| @@ -973,7 +973,7 @@ static int estimate_best_b_count(MpegEncContext *s){ | |||
| c->time_base= s->avctx->time_base; | |||
| c->max_b_frames= s->max_b_frames; | |||
| if (avcodec_open(c, codec) < 0) | |||
| if (avcodec_open2(c, codec, NULL) < 0) | |||
| return -1; | |||
| for(i=0; i<s->max_b_frames+2; i++){ | |||
| @@ -471,7 +471,8 @@ static int decode_frame(AVCodecContext *avctx, | |||
| avctx->pix_fmt = PIX_FMT_MONOBLACK; | |||
| } else if (s->color_type == PNG_COLOR_TYPE_PALETTE) { | |||
| avctx->pix_fmt = PIX_FMT_PAL8; | |||
| } else if (s->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { | |||
| } else if (s->bit_depth == 8 && | |||
| s->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { | |||
| avctx->pix_fmt = PIX_FMT_GRAY8A; | |||
| } else { | |||
| goto fail; | |||
| @@ -76,6 +76,7 @@ do { \ | |||
| #define SAMPLES_NEEDED_2(why) \ | |||
| av_log (NULL,AV_LOG_INFO,"This file triggers some missing code. Please contact the developers.\nPosition: %s\n",why); | |||
| #define QDM2_MAX_FRAME_SIZE 512 | |||
| typedef int8_t sb_int8_array[2][30][64]; | |||
| @@ -168,7 +169,7 @@ typedef struct { | |||
| /// I/O data | |||
| const uint8_t *compressed_data; | |||
| int compressed_size; | |||
| float output_buffer[1024]; | |||
| float output_buffer[QDM2_MAX_FRAME_SIZE * MPA_MAX_CHANNELS * 2]; | |||
| /// Synthesis filter | |||
| MPADSPContext mpadsp; | |||
| @@ -1327,7 +1328,7 @@ static void qdm2_fft_decode_tones (QDM2Context *q, int duration, GetBitContext * | |||
| local_int_10 = 1 << (q->group_order - duration - 1); | |||
| offset = 1; | |||
| while (1) { | |||
| while (get_bits_left(gb)>0) { | |||
| if (q->superblocktype_2_3) { | |||
| while ((n = qdm2_get_vlc(gb, &vlc_tab_fft_tone_offset[local_int_8], 1, 2)) < 2) { | |||
| offset = 1; | |||
| @@ -1822,7 +1823,8 @@ static av_cold int qdm2_decode_init(AVCodecContext *avctx) | |||
| // something like max decodable tones | |||
| s->group_order = av_log2(s->group_size) + 1; | |||
| s->frame_size = s->group_size / 16; // 16 iterations per super block | |||
| if (s->frame_size > FF_ARRAY_ELEMS(s->output_buffer) / 2) | |||
| if (s->frame_size > QDM2_MAX_FRAME_SIZE) | |||
| return AVERROR_INVALIDDATA; | |||
| s->sub_sampling = s->fft_order - 7; | |||
| @@ -1893,6 +1895,9 @@ static int qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out) | |||
| int ch, i; | |||
| const int frame_size = (q->frame_size * q->channels); | |||
| if((unsigned)frame_size > FF_ARRAY_ELEMS(q->output_buffer)/2) | |||
| return -1; | |||
| /* select input buffer */ | |||
| q->compressed_data = in; | |||
| q->compressed_size = q->checksum_size; | |||
| @@ -658,6 +658,7 @@ static int svq1_decode_frame(AVCodecContext *avctx, | |||
| av_dlog(s->avctx, "Error in svq1_decode_frame_header %i\n",result); | |||
| return result; | |||
| } | |||
| avcodec_set_dimensions(avctx, s->width, s->height); | |||
| //FIXME this avoids some confusion for "B frames" without 2 references | |||
| //this should be removed after libavcodec can handle more flexible picture types & ordering | |||
| @@ -32,6 +32,7 @@ | |||
| #include "libavutil/audioconvert.h" | |||
| #include "libavutil/imgutils.h" | |||
| #include "libavutil/samplefmt.h" | |||
| #include "libavutil/dict.h" | |||
| #include "avcodec.h" | |||
| #include "dsputil.h" | |||
| #include "libavutil/opt.h" | |||
| @@ -498,9 +499,20 @@ static void avcodec_get_subtitle_defaults(AVSubtitle *sub) | |||
| sub->pts = AV_NOPTS_VALUE; | |||
| } | |||
| #if FF_API_AVCODEC_OPEN | |||
| int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec) | |||
| { | |||
| return avcodec_open2(avctx, codec, NULL); | |||
| } | |||
| #endif | |||
| int attribute_align_arg avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options) | |||
| { | |||
| int ret = 0; | |||
| AVDictionary *tmp = NULL; | |||
| if (options) | |||
| av_dict_copy(&tmp, *options, 0); | |||
| /* If there is a user-supplied mutex locking routine, call it. */ | |||
| if (ff_lockmgr_cb) { | |||
| @@ -527,14 +539,18 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec) | |||
| ret = AVERROR(ENOMEM); | |||
| goto end; | |||
| } | |||
| if(codec->priv_class){ //this can be droped once all user apps use avcodec_get_context_defaults3() | |||
| if (codec->priv_class) { | |||
| *(AVClass**)avctx->priv_data= codec->priv_class; | |||
| av_opt_set_defaults(avctx->priv_data); | |||
| } | |||
| } | |||
| if (codec->priv_class && (ret = av_opt_set_dict(avctx->priv_data, &tmp)) < 0) | |||
| goto free_and_end; | |||
| } else { | |||
| avctx->priv_data = NULL; | |||
| } | |||
| if ((ret = av_opt_set_dict(avctx, &tmp)) < 0) | |||
| goto free_and_end; | |||
| if(avctx->coded_width && avctx->coded_height) | |||
| avcodec_set_dimensions(avctx, avctx->coded_width, avctx->coded_height); | |||
| @@ -655,8 +671,14 @@ end: | |||
| if (ff_lockmgr_cb) { | |||
| (*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE); | |||
| } | |||
| if (options) { | |||
| av_dict_free(options); | |||
| *options = tmp; | |||
| } | |||
| return ret; | |||
| free_and_end: | |||
| av_dict_free(&tmp); | |||
| av_freep(&avctx->priv_data); | |||
| avctx->codec= NULL; | |||
| goto end; | |||
| @@ -21,7 +21,7 @@ | |||
| #define AVCODEC_VERSION_H | |||
| #define LIBAVCODEC_VERSION_MAJOR 52 | |||
| #define LIBAVCODEC_VERSION_MINOR 122 | |||
| #define LIBAVCODEC_VERSION_MINOR 123 | |||
| #define LIBAVCODEC_VERSION_MICRO 0 | |||
| #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ | |||
| @@ -101,5 +101,8 @@ | |||
| #ifndef FF_API_GET_PIX_FMT_NAME | |||
| #define FF_API_GET_PIX_FMT_NAME (LIBAVCODEC_VERSION_MAJOR < 54) | |||
| #endif | |||
| #ifndef FF_API_AVCODEC_OPEN | |||
| #define FF_API_AVCODEC_OPEN (LIBAVCODEC_VERSION_MAJOR < 54) | |||
| #endif | |||
| #endif /* AVCODEC_VERSION_H */ | |||
| @@ -1308,6 +1308,10 @@ static inline int vp3_dequant(Vp3DecodeContext *s, Vp3Fragment *frag, | |||
| case 1: // zero run | |||
| s->dct_tokens[plane][i]++; | |||
| i += (token >> 2) & 0x7f; | |||
| if(i>63){ | |||
| av_log(s->avctx, AV_LOG_ERROR, "Coefficient index overflow\n"); | |||
| return -1; | |||
| } | |||
| block[perm[i]] = (token >> 9) * dequantizer[perm[i]]; | |||
| i++; | |||
| break; | |||
| @@ -183,7 +183,8 @@ static void vp5_parse_coeff(VP56Context *s) | |||
| model1 = model->coeff_dccv[pt]; | |||
| model2 = model->coeff_dcct[pt][ctx]; | |||
| for (coeff_idx=0; coeff_idx<64; ) { | |||
| coeff_idx = 0; | |||
| for (;;) { | |||
| if (vp56_rac_get_prob(c, model2[0])) { | |||
| if (vp56_rac_get_prob(c, model2[2])) { | |||
| if (vp56_rac_get_prob(c, model2[3])) { | |||
| @@ -220,8 +221,11 @@ static void vp5_parse_coeff(VP56Context *s) | |||
| ct = 0; | |||
| s->coeff_ctx[vp56_b6to4[b]][coeff_idx] = 0; | |||
| } | |||
| coeff_idx++; | |||
| if (coeff_idx >= 64) | |||
| break; | |||
| cg = vp5_coeff_groups[++coeff_idx]; | |||
| cg = vp5_coeff_groups[coeff_idx]; | |||
| ctx = s->coeff_ctx[vp56_b6to4[b]][coeff_idx]; | |||
| model1 = model->coeff_ract[pt][ct][cg]; | |||
| model2 = cg > 2 ? model1 : model->coeff_acct[pt][ct][cg][ctx]; | |||
| @@ -440,7 +440,8 @@ static void vp6_parse_coeff(VP56Context *s) | |||
| model1 = model->coeff_dccv[pt]; | |||
| model2 = model->coeff_dcct[pt][ctx]; | |||
| for (coeff_idx=0; coeff_idx<64; ) { | |||
| coeff_idx = 0; | |||
| for (;;) { | |||
| if ((coeff_idx>1 && ct==0) || vp56_rac_get_prob(c, model2[0])) { | |||
| /* parse a coeff */ | |||
| if (vp56_rac_get_prob(c, model2[2])) { | |||
| @@ -481,8 +482,10 @@ static void vp6_parse_coeff(VP56Context *s) | |||
| run += vp56_rac_get_prob(c, model3[i+8]) << i; | |||
| } | |||
| } | |||
| cg = vp6_coeff_groups[coeff_idx+=run]; | |||
| coeff_idx += run; | |||
| if (coeff_idx >= 64) | |||
| break; | |||
| cg = vp6_coeff_groups[coeff_idx]; | |||
| model1 = model2 = model->coeff_ract[pt][ct][cg]; | |||
| } | |||
| @@ -109,6 +109,11 @@ static int wma_decode_init(AVCodecContext * avctx) | |||
| } | |||
| } | |||
| if(avctx->channels > MAX_CHANNELS){ | |||
| av_log(avctx, AV_LOG_ERROR, "Invalid number of channels (%d)\n", avctx->channels); | |||
| return -1; | |||
| } | |||
| if(ff_wma_init(avctx, flags2)<0) | |||
| return -1; | |||
| @@ -439,7 +439,7 @@ static int v4l2_set_parameters(AVFormatContext *s1, AVFormatParameters *ap) | |||
| struct v4l2_streamparm streamparm = {0}; | |||
| struct v4l2_fract *tpf = &streamparm.parm.capture.timeperframe; | |||
| int i, ret; | |||
| AVRational fps; | |||
| AVRational fps={0}; | |||
| streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | |||
| @@ -69,16 +69,13 @@ static int query_formats(AVFilterContext *ctx) | |||
| PIX_FMT_BGR555BE, PIX_FMT_BGR555LE, | |||
| PIX_FMT_GRAY16BE, PIX_FMT_GRAY16LE, | |||
| PIX_FMT_YUV420P16LE, PIX_FMT_YUV420P16BE, | |||
| PIX_FMT_YUV422P16LE, PIX_FMT_YUV422P16BE, | |||
| PIX_FMT_YUV444P16LE, PIX_FMT_YUV444P16BE, | |||
| PIX_FMT_NV12, PIX_FMT_NV21, | |||
| PIX_FMT_RGB8, PIX_FMT_BGR8, | |||
| PIX_FMT_RGB4_BYTE, PIX_FMT_BGR4_BYTE, | |||
| PIX_FMT_YUV444P, PIX_FMT_YUV422P, | |||
| PIX_FMT_YUV444P, PIX_FMT_YUVJ444P, | |||
| PIX_FMT_YUV420P, PIX_FMT_YUVJ420P, | |||
| PIX_FMT_YUV411P, PIX_FMT_YUV410P, | |||
| PIX_FMT_YUVJ444P, PIX_FMT_YUVJ422P, | |||
| PIX_FMT_YUV440P, PIX_FMT_YUVJ440P, | |||
| PIX_FMT_YUV410P, | |||
| PIX_FMT_YUVA420P, PIX_FMT_GRAY8, | |||
| PIX_FMT_NONE | |||
| }; | |||
| @@ -248,6 +248,7 @@ OBJS-$(CONFIG_RTPDEC) += rdt.o \ | |||
| rtpdec.o \ | |||
| rtpdec_amr.o \ | |||
| rtpdec_asf.o \ | |||
| rtpdec_g726.o \ | |||
| rtpdec_h263.o \ | |||
| rtpdec_h264.o \ | |||
| rtpdec_latm.o \ | |||
| @@ -40,6 +40,8 @@ static int ac3_eac3_probe(AVProbeData *p, enum CodecID expected_codec_id) | |||
| buf2 = buf; | |||
| for(frames = 0; buf2 < end; frames++) { | |||
| if(!memcmp(buf2, "\x1\x10\0\0\0\0\0\0", 8)) | |||
| buf2+=16; | |||
| init_get_bits(&gbc, buf2, 54); | |||
| if(ff_ac3_parse_header(&gbc, &hdr) < 0) | |||
| break; | |||
| @@ -1238,6 +1238,7 @@ AVFormatContext *avformat_alloc_output_context(const char *format, | |||
| int avformat_alloc_output_context2(AVFormatContext **ctx, AVOutputFormat *oformat, | |||
| const char *format_name, const char *filename); | |||
| #if FF_API_FORMAT_PARAMETERS | |||
| /** | |||
| * Read packets of a media file to get stream information. This | |||
| * is useful for file formats with no headers such as MPEG. This | |||
| @@ -1250,8 +1251,34 @@ int avformat_alloc_output_context2(AVFormatContext **ctx, AVOutputFormat *oforma | |||
| * @return >=0 if OK, AVERROR_xxx on error | |||
| * @todo Let the user decide somehow what information is needed so that | |||
| * we do not waste time getting stuff the user does not need. | |||
| * | |||
| * @deprecated use avformat_find_stream_info. | |||
| */ | |||
| int av_find_stream_info(AVFormatContext *ic); | |||
| #endif | |||
| /** | |||
| * Read packets of a media file to get stream information. This | |||
| * is useful for file formats with no headers such as MPEG. This | |||
| * function also computes the real framerate in case of MPEG-2 repeat | |||
| * frame mode. | |||
| * The logical file position is not changed by this function; | |||
| * examined packets may be buffered for later processing. | |||
| * | |||
| * @param ic media file handle | |||
| * @param options If non-NULL, an ic.nb_streams long array of pointers to | |||
| * dictionaries, where i-th member contains options for | |||
| * codec corresponding to i-th stream. | |||
| * On return each dictionary will be filled with options that were not found. | |||
| * @return >=0 if OK, AVERROR_xxx on error | |||
| * | |||
| * @note this function isn't guaranteed to open all the codecs, so | |||
| * options being non-empty at return is a perfectly normal behavior. | |||
| * | |||
| * @todo Let the user decide somehow what information is needed so that | |||
| * we do not waste time getting stuff the user does not need. | |||
| */ | |||
| int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options); | |||
| /** | |||
| * Find the "best" stream in the file. | |||
| @@ -59,6 +59,12 @@ int ff_raw_read_header(AVFormatContext *s, AVFormatParameters *ap) | |||
| if (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->channels) | |||
| st->codec->channels = s1->channels; | |||
| @@ -246,7 +252,7 @@ AVInputFormat ff_gsm_demuxer = { | |||
| #endif | |||
| #if CONFIG_MJPEG_DEMUXER | |||
| FF_DEF_RAWVIDEO_DEMUXER(mjpeg, "raw MJPEG video", NULL, "mjpg,mjpeg", CODEC_ID_MJPEG) | |||
| FF_DEF_RAWVIDEO_DEMUXER(mjpeg, "raw MJPEG video", NULL, "mjpg,mjpeg,mpo", CODEC_ID_MJPEG) | |||
| #endif | |||
| #if CONFIG_MLP_DEMUXER | |||
| @@ -82,6 +82,11 @@ void av_register_rtp_dynamic_payload_handlers(void) | |||
| ff_register_dynamic_payload_handler(&ff_qt_rtp_vid_handler); | |||
| ff_register_dynamic_payload_handler(&ff_quicktime_rtp_aud_handler); | |||
| ff_register_dynamic_payload_handler(&ff_quicktime_rtp_vid_handler); | |||
| ff_register_dynamic_payload_handler(&ff_g726_16_dynamic_handler); | |||
| ff_register_dynamic_payload_handler(&ff_g726_24_dynamic_handler); | |||
| ff_register_dynamic_payload_handler(&ff_g726_32_dynamic_handler); | |||
| ff_register_dynamic_payload_handler(&ff_g726_40_dynamic_handler); | |||
| } | |||
| RTPDynamicProtocolHandler *ff_rtp_handler_find_by_name(const char *name, | |||
| @@ -33,6 +33,10 @@ int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p); | |||
| extern RTPDynamicProtocolHandler ff_amr_nb_dynamic_handler; | |||
| extern RTPDynamicProtocolHandler ff_amr_wb_dynamic_handler; | |||
| extern RTPDynamicProtocolHandler ff_g726_16_dynamic_handler; | |||
| extern RTPDynamicProtocolHandler ff_g726_24_dynamic_handler; | |||
| extern RTPDynamicProtocolHandler ff_g726_32_dynamic_handler; | |||
| extern RTPDynamicProtocolHandler ff_g726_40_dynamic_handler; | |||
| extern RTPDynamicProtocolHandler ff_h263_1998_dynamic_handler; | |||
| extern RTPDynamicProtocolHandler ff_h263_2000_dynamic_handler; | |||
| extern RTPDynamicProtocolHandler ff_h264_dynamic_handler; | |||
| @@ -0,0 +1,94 @@ | |||
| /* | |||
| * Copyright (c) 2011 Miroslav Slugeň <Thunder.m@seznam.cz> | |||
| * | |||
| * 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 | |||
| */ | |||
| #include "avformat.h" | |||
| #include "rtpdec_formats.h" | |||
| static int g726_16_parse_sdp_line(AVFormatContext *s, int st_index, | |||
| PayloadContext *data, const char *line) | |||
| { | |||
| AVStream *stream = s->streams[st_index]; | |||
| AVCodecContext *codec = stream->codec; | |||
| codec->bit_rate = 16000; | |||
| return 0; | |||
| } | |||
| static int g726_24_parse_sdp_line(AVFormatContext *s, int st_index, | |||
| PayloadContext *data, const char *line) | |||
| { | |||
| AVStream *stream = s->streams[st_index]; | |||
| AVCodecContext *codec = stream->codec; | |||
| codec->bit_rate = 24000; | |||
| return 0; | |||
| } | |||
| static int g726_32_parse_sdp_line(AVFormatContext *s, int st_index, | |||
| PayloadContext *data, const char *line) | |||
| { | |||
| AVStream *stream = s->streams[st_index]; | |||
| AVCodecContext *codec = stream->codec; | |||
| codec->bit_rate = 32000; | |||
| return 0; | |||
| } | |||
| static int g726_40_parse_sdp_line(AVFormatContext *s, int st_index, | |||
| PayloadContext *data, const char *line) | |||
| { | |||
| AVStream *stream = s->streams[st_index]; | |||
| AVCodecContext *codec = stream->codec; | |||
| codec->bit_rate = 40000; | |||
| return 0; | |||
| } | |||
| RTPDynamicProtocolHandler ff_g726_16_dynamic_handler = { | |||
| .enc_name = "G726-16", | |||
| .codec_type = AVMEDIA_TYPE_AUDIO, | |||
| .codec_id = CODEC_ID_ADPCM_G726, | |||
| .parse_sdp_a_line = g726_16_parse_sdp_line, | |||
| }; | |||
| RTPDynamicProtocolHandler ff_g726_24_dynamic_handler = { | |||
| .enc_name = "G726-24", | |||
| .codec_type = AVMEDIA_TYPE_AUDIO, | |||
| .codec_id = CODEC_ID_ADPCM_G726, | |||
| .parse_sdp_a_line = g726_24_parse_sdp_line, | |||
| }; | |||
| RTPDynamicProtocolHandler ff_g726_32_dynamic_handler = { | |||
| .enc_name = "G726-32", | |||
| .codec_type = AVMEDIA_TYPE_AUDIO, | |||
| .codec_id = CODEC_ID_ADPCM_G726, | |||
| .parse_sdp_a_line = g726_32_parse_sdp_line, | |||
| }; | |||
| RTPDynamicProtocolHandler ff_g726_40_dynamic_handler = { | |||
| .enc_name = "G726-40", | |||
| .codec_type = AVMEDIA_TYPE_AUDIO, | |||
| .codec_id = CODEC_ID_ADPCM_G726, | |||
| .parse_sdp_a_line = g726_40_parse_sdp_line, | |||
| }; | |||
| @@ -2190,7 +2190,7 @@ static int has_decode_delay_been_guessed(AVStream *st) | |||
| st->codec_info_nb_frames >= 6 + st->codec->has_b_frames; | |||
| } | |||
| static int try_decode_frame(AVStream *st, AVPacket *avpkt) | |||
| static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **options) | |||
| { | |||
| int16_t *samples; | |||
| AVCodec *codec; | |||
| @@ -2201,7 +2201,7 @@ static int try_decode_frame(AVStream *st, AVPacket *avpkt) | |||
| codec = avcodec_find_decoder(st->codec->codec_id); | |||
| if (!codec) | |||
| return -1; | |||
| ret = avcodec_open(st->codec, codec); | |||
| ret = avcodec_open2(st->codec, codec, options); | |||
| if (ret < 0) | |||
| return ret; | |||
| } | |||
| @@ -2320,12 +2320,20 @@ static int tb_unreliable(AVCodecContext *c){ | |||
| return 0; | |||
| } | |||
| #if FF_API_FORMAT_PARAMETERS | |||
| int av_find_stream_info(AVFormatContext *ic) | |||
| { | |||
| return avformat_find_stream_info(ic, NULL); | |||
| } | |||
| #endif | |||
| int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) | |||
| { | |||
| int i, count, ret, read_size, j; | |||
| AVStream *st; | |||
| AVPacket pkt1, *pkt; | |||
| int64_t old_offset = avio_tell(ic->pb); | |||
| int orig_nb_streams = ic->nb_streams; // new streams might appear, no options for those | |||
| for(i=0;i<ic->nb_streams;i++) { | |||
| AVCodec *codec; | |||
| @@ -2362,12 +2370,12 @@ int av_find_stream_info(AVFormatContext *ic) | |||
| /* Ensure that subtitle_header is properly set. */ | |||
| if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE | |||
| && codec && !st->codec->codec) | |||
| avcodec_open(st->codec, codec); | |||
| avcodec_open2(st->codec, codec, options ? &options[i] : NULL); | |||
| //try to just open decoders, in case this is enough to get parameters | |||
| if(!has_codec_parameters(st->codec)){ | |||
| if (codec && !st->codec->codec) | |||
| avcodec_open(st->codec, codec); | |||
| avcodec_open2(st->codec, codec, options ? &options[i] : NULL); | |||
| } | |||
| } | |||
| @@ -2477,7 +2485,7 @@ int av_find_stream_info(AVFormatContext *ic) | |||
| for (i=1; i<FF_ARRAY_ELEMS(st->info->duration_error); i++) { | |||
| int framerate= get_std_framerate(i); | |||
| int ticks= lrintf(dur*framerate/(1001*12)); | |||
| double error= dur - ticks*1001*12/(double)framerate; | |||
| double error = dur - (double)ticks*1001*12 / framerate; | |||
| st->info->duration_error[i] += error*error; | |||
| } | |||
| st->info->duration_count++; | |||
| @@ -2503,7 +2511,7 @@ int av_find_stream_info(AVFormatContext *ic) | |||
| it takes longer and uses more memory. For MPEG-4, we need to | |||
| decompress for QuickTime. */ | |||
| if (!has_codec_parameters(st->codec) || !has_decode_delay_been_guessed(st)) | |||
| try_decode_frame(st, pkt); | |||
| try_decode_frame(st, pkt, (options && i < orig_nb_streams )? &options[i] : NULL); | |||
| st->codec_info_nb_frames++; | |||
| count++; | |||
| @@ -24,7 +24,7 @@ | |||
| #include "libavutil/avutil.h" | |||
| #define LIBAVFORMAT_VERSION_MAJOR 52 | |||
| #define LIBAVFORMAT_VERSION_MINOR 110 | |||
| #define LIBAVFORMAT_VERSION_MINOR 111 | |||
| #define LIBAVFORMAT_VERSION_MICRO 0 | |||
| #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ | |||
| @@ -125,7 +125,7 @@ int av_image_fill_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int heigh | |||
| has_plane[desc->comp[i].plane] = 1; | |||
| total_size = size[0]; | |||
| for (i = 1; has_plane[i] && i < 4; i++) { | |||
| for (i = 1; i < 4 && has_plane[i]; i++) { | |||
| int h, s = (i == 1 || i == 2) ? desc->log2_chroma_h : 0; | |||
| data[i] = data[i-1] + size[i-1]; | |||
| h = (height + (1 << s) - 1) >> s; | |||