* qatar/master: (47 commits) lavc: hide private symbols. lavc: deprecate img_get_alpha_info(). lavc: use avpriv_ prefix for ff_toupper4. lavc: use avpriv_ prefix for ff_copy_bits and align_put_bits. lavc: use avpriv_ prefix for ff_ac3_parse_header. lavc: use avpriv_ prefix for ff_frame_rate_tab. lavc: rename ff_find_start_code to avpriv_mpv_find_start_code lavc: use avpriv_ prefix for ff_split_xiph_headers. lavc: use avpriv_ prefix for ff_dirac_parse_sequence_header. lavc: use avpriv_ prefix for some dv symbols used in lavf. lavc: use avpriv_ prefix for some flac symbols used in lavf. lavc: use avpriv_ prefix for some mpeg4audio symbols used in lavf. lavc: use avpriv_ prefix for some mpegaudio symbols used in lavf. lavc: use avpriv_ prefix for ff_aac_parse_header(). lavf: hide private symbols. lavf: use avpriv_ prefix for some dv functions. lavf: use avpriv_ prefix for ff_new_chapter(). avcodec: add CODEC_CAP_DELAY note to avcodec_decode_audio3() documentation avcodec: clarify the CODEC_CAP_DELAY note in avcodec_decode_video2() avcodec: clarify documentation of CODEC_CAP_DELAY ... Conflicts: configure doc/general.texi libavcodec/Makefile libavcodec/aacdec.c libavcodec/allcodecs.c libavcodec/avcodec.h libavcodec/dv.c libavcodec/dvdata.c libavcodec/dvdata.h libavcodec/libspeexenc.c libavcodec/mpegvideo.c libavcodec/version.h libavformat/avidec.c libavformat/dv.c libavformat/dv.h libavformat/flvenc.c libavformat/mov.c libavformat/mp3enc.c libavformat/oggparsespeex.c
Unified · Split
| @@ -66,6 +66,7 @@ easier to use. The changes are: · 65 unmodified lines | ||
| 66 | 66 | - libutvideo wrapper (--enable-libutvideo) |
| 67 | 67 | - aevalsrc audio source added |
| 68 | 68 | - Ut Video decoder |
| 69 | +- Speex encoding via libspeex | |
| 69 | 70 | |
| 70 | 71 | |
| 71 | 72 | version 0.8: |
| @@ -182,7 +182,7 @@ External library support: · 181 unmodified lines | ||
| 182 | 182 | --enable-libopenjpeg enable JPEG 2000 decoding via OpenJPEG [no] |
| 183 | 183 | --enable-librtmp enable RTMP[E] support via librtmp [no] |
| 184 | 184 | --enable-libschroedinger enable Dirac support via libschroedinger [no] |
| 185 | − --enable-libspeex enable Speex encoding and decoding via libspeex [no] | |
| 185 | + --enable-libspeex enable Speex support via libspeex [no] | |
| 186 | 186 | --enable-libstagefright-h264 enable H.264 decoding via libstagefright [no] |
| 187 | 187 | --enable-libtheora enable Theora encoding via libtheora [no] |
| 188 | 188 | --enable-libutvideo enable Ut Video decoding via libutvideo [no] |
| @@ -702,6 +702,7 @@ SKIPHEADERS-$(CONFIG_LIBSCHROEDINGER) += libschroedinger.h · 701 unmodified lines | ||
| 702 | 702 | SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_internal.h |
| 703 | 703 | SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h |
| 704 | 704 | SKIPHEADERS-$(CONFIG_XVMC) += xvmc.h |
| 705 | +SKIPHEADERS-$(HAVE_W32THREADS) += w32pthreads.h | |
| 705 | 706 | |
| 706 | 707 | TESTPROGS = cabac dct fft fft-fixed h264 iirfilter rangecoder snow |
| 707 | 708 | TESTPROGS-$(HAVE_MMX) += motion |
| @@ -55,7 +55,7 @@ static int aac_adtstoasc_filter(AVBitStreamFilterContext *bsfc, · 54 unmodified lines | ||
| 55 | 55 | if (show_bits(&gb, 12) != 0xfff) |
| 56 | 56 | return 0; |
| 57 | 57 | |
| 58 | − if (ff_aac_parse_header(&gb, &hdr) < 0) { | |
| 58 | + if (avpriv_aac_parse_header(&gb, &hdr) < 0) { | |
| 59 | 59 | av_log(avctx, AV_LOG_ERROR, "Error parsing ADTS frame header!\n"); |
| 60 | 60 | return -1; |
| 61 | 61 | } |
| @@ -78,7 +78,7 @@ static int aac_adtstoasc_filter(AVBitStreamFilterContext *bsfc, · 16 unmodified lines | ||
| 78 | 78 | return -1; |
| 79 | 79 | } |
| 80 | 80 | init_put_bits(&pb, pce_data, MAX_PCE_SIZE); |
| 81 | − pce_size = ff_copy_pce_data(&pb, &gb)/8; | |
| 81 | + pce_size = avpriv_copy_pce_data(&pb, &gb)/8; | |
| 82 | 82 | flush_put_bits(&pb); |
| 83 | 83 | buf_size -= get_bits_count(&gb)/8; |
| 84 | 84 | buf += get_bits_count(&gb)/8; |
| @@ -40,7 +40,7 @@ static int aac_sync(uint64_t state, AACAC3ParseContext *hdr_info, · 39 unmodified lines | ||
| 40 | 40 | tmp.u64 = av_be2ne64(state); |
| 41 | 41 | init_get_bits(&bits, tmp.u8+8-AAC_ADTS_HEADER_SIZE, AAC_ADTS_HEADER_SIZE * 8); |
| 42 | 42 | |
| 43 | − if ((size = ff_aac_parse_header(&bits, &hdr)) < 0) | |
| 43 | + if ((size = avpriv_aac_parse_header(&bits, &hdr)) < 0) | |
| 44 | 44 | return 0; |
| 45 | 45 | *need_next_header = 0; |
| 46 | 46 | *new_frame_start = 1; |
| @@ -26,7 +26,7 @@ · 25 unmodified lines | ||
| 26 | 26 | #include "get_bits.h" |
| 27 | 27 | #include "mpeg4audio.h" |
| 28 | 28 | |
| 29 | −int ff_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr) | |
| 29 | +int avpriv_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr) | |
| 30 | 30 | { |
| 31 | 31 | int size, rdb, ch, sr; |
| 32 | 32 | int aot, crc_abs; |
| @@ -39,7 +39,7 @@ int ff_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr) · 6 unmodified lines | ||
| 39 | 39 | crc_abs = get_bits1(gbc); /* protection_absent */ |
| 40 | 40 | aot = get_bits(gbc, 2); /* profile_objecttype */ |
| 41 | 41 | sr = get_bits(gbc, 4); /* sample_frequency_index */ |
| 42 | − if(!ff_mpeg4audio_sample_rates[sr]) | |
| 42 | + if(!avpriv_mpeg4audio_sample_rates[sr]) | |
| 43 | 43 | return AAC_AC3_PARSE_ERROR_SAMPLE_RATE; |
| 44 | 44 | skip_bits1(gbc); /* private_bit */ |
| 45 | 45 | ch = get_bits(gbc, 3); /* channel_configuration */ |
| @@ -62,7 +62,7 @@ int ff_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr) · 16 unmodified lines | ||
| 62 | 62 | hdr->crc_absent = crc_abs; |
| 63 | 63 | hdr->num_aac_frames = rdb + 1; |
| 64 | 64 | hdr->sampling_index = sr; |
| 65 | − hdr->sample_rate = ff_mpeg4audio_sample_rates[sr]; | |
| 65 | + hdr->sample_rate = avpriv_mpeg4audio_sample_rates[sr]; | |
| 66 | 66 | hdr->samples = (rdb + 1) * 1024; |
| 67 | 67 | hdr->bit_rate = size * 8 * hdr->sample_rate / hdr->samples; |
| 68 | 68 | |
| @@ -49,6 +49,6 @@ typedef struct { · 48 unmodified lines | ||
| 49 | 49 | * -2 if the version element is invalid, -3 if the sample rate |
| 50 | 50 | * element is invalid, or -4 if the bit rate element is invalid. |
| 51 | 51 | */ |
| 52 | −int ff_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr); | |
| 52 | +int avpriv_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr); | |
| 53 | 53 | |
| 54 | 54 | #endif /* AVCODEC_AACADTSDEC_H */ |
| @@ -472,7 +472,7 @@ static int decode_audio_specific_config(AACContext *ac, · 471 unmodified lines | ||
| 472 | 472 | |
| 473 | 473 | init_get_bits(&gb, data, data_size * 8); |
| 474 | 474 | |
| 475 | − if ((i = ff_mpeg4audio_get_config(m4ac, data, asclen/8)) < 0) | |
| 475 | + if ((i = avpriv_mpeg4audio_get_config(m4ac, data, asclen/8)) < 0) | |
| 476 | 476 | return -1; |
| 477 | 477 | if (m4ac->sampling_index > 12) { |
| 478 | 478 | av_log(avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", m4ac->sampling_index); |
| @@ -2077,7 +2077,7 @@ static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb) · 1598 unmodified lines | ||
| 2077 | 2077 | int size; |
| 2078 | 2078 | AACADTSHeaderInfo hdr_info; |
| 2079 | 2079 | |
| 2080 | − size = ff_aac_parse_header(gb, &hdr_info); | |
| 2080 | + size = avpriv_aac_parse_header(gb, &hdr_info); | |
| 2081 | 2081 | if (size > 0) { |
| 2082 | 2082 | if (hdr_info.chan_config) { |
| 2083 | 2083 | enum ChannelPosition new_che_pos[4][MAX_ELEM_ID]; |
| @@ -180,7 +180,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) · 179 unmodified lines | ||
| 180 | 180 | avctx->frame_size = 1024; |
| 181 | 181 | |
| 182 | 182 | for (i = 0; i < 16; i++) |
| 183 | − if (avctx->sample_rate == ff_mpeg4audio_sample_rates[i]) | |
| 183 | + if (avctx->sample_rate == avpriv_mpeg4audio_sample_rates[i]) | |
| 184 | 184 | break; |
| 185 | 185 | if (i == 16) { |
| 186 | 186 | av_log(avctx, AV_LOG_ERROR, "Unsupported sample rate %d\n", avctx->sample_rate); |
| @@ -491,7 +491,7 @@ static void put_bitstream_info(AVCodecContext *avctx, AACEncContext *s, · 304 unmodified lines | ||
| 491 | 491 | put_bits(&s->pb, 8, namelen - 16); |
| 492 | 492 | put_bits(&s->pb, 4, 0); //extension type - filler |
| 493 | 493 | padbits = 8 - (put_bits_count(&s->pb) & 7); |
| 494 | − align_put_bits(&s->pb); | |
| 494 | + avpriv_align_put_bits(&s->pb); | |
| 495 | 495 | for (i = 0; i < namelen - 2; i++) |
| 496 | 496 | put_bits(&s->pb, 8, name[i]); |
| 497 | 497 | put_bits(&s->pb, 12 - padbits, 0); |
| @@ -35,7 +35,7 @@ static const uint8_t eac3_blocks[4] = { · 34 unmodified lines | ||
| 35 | 35 | }; |
| 36 | 36 | |
| 37 | 37 | |
| 38 | −int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr) | |
| 38 | +int avpriv_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr) | |
| 39 | 39 | { |
| 40 | 40 | int frame_size_code; |
| 41 | 41 | |
| @@ -141,7 +141,7 @@ static int ac3_sync(uint64_t state, AACAC3ParseContext *hdr_info, · 99 unmodified lines | ||
| 141 | 141 | GetBitContext gbc; |
| 142 | 142 | |
| 143 | 143 | init_get_bits(&gbc, tmp.u8+8-AC3_HEADER_SIZE, 54); |
| 144 | − err = ff_ac3_parse_header(&gbc, &hdr); | |
| 144 | + err = avpriv_ac3_parse_header(&gbc, &hdr); | |
| 145 | 145 | |
| 146 | 146 | if(err < 0) |
| 147 | 147 | return 0; |
| @@ -36,6 +36,6 @@ · 35 unmodified lines | ||
| 36 | 36 | * -2 if the bsid (version) element is invalid, -3 if the fscod (sample rate) |
| 37 | 37 | * element is invalid, or -4 if the frmsizecod (bit rate) element is invalid. |
| 38 | 38 | */ |
| 39 | −int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr); | |
| 39 | +int avpriv_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr); | |
| 40 | 40 | |
| 41 | 41 | #endif /* AVCODEC_AC3_PARSER_H */ |
| @@ -261,7 +261,7 @@ static int parse_frame_header(AC3DecodeContext *s) · 260 unmodified lines | ||
| 261 | 261 | AC3HeaderInfo hdr; |
| 262 | 262 | int err; |
| 263 | 263 | |
| 264 | − err = ff_ac3_parse_header(&s->gbc, &hdr); | |
| 264 | + err = avpriv_ac3_parse_header(&s->gbc, &hdr); | |
| 265 | 265 | if(err) |
| 266 | 266 | return err; |
| 267 | 267 | |
| @@ -289,7 +289,7 @@ static av_cold int read_specific_config(ALSDecContext *ctx) · 288 unmodified lines | ||
| 289 | 289 | |
| 290 | 290 | init_get_bits(&gb, avctx->extradata, avctx->extradata_size * 8); |
| 291 | 291 | |
| 292 | − config_offset = ff_mpeg4audio_get_config(&m4ac, avctx->extradata, | |
| 292 | + config_offset = avpriv_mpeg4audio_get_config(&m4ac, avctx->extradata, | |
| 293 | 293 | avctx->extradata_size); |
| 294 | 294 | |
| 295 | 295 | if (config_offset < 0) |
| @@ -497,7 +497,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, · 496 unmodified lines | ||
| 497 | 497 | } |
| 498 | 498 | emms_c(); |
| 499 | 499 | |
| 500 | − align_put_bits(&a->pb); | |
| 500 | + avpriv_align_put_bits(&a->pb); | |
| 501 | 501 | while(put_bits_count(&a->pb)&31) |
| 502 | 502 | put_bits(&a->pb, 8, 0); |
| 503 | 503 | |
| @@ -210,8 +210,10 @@ enum CodecID { · 209 unmodified lines | ||
| 210 | 210 | CODEC_ID_DFA, |
| 211 | 211 | CODEC_ID_WMV3IMAGE, |
| 212 | 212 | CODEC_ID_VC1IMAGE, |
| 213 | +#if LIBAVCODEC_VERSION_MAJOR == 53 | |
| 213 | 214 | CODEC_ID_8SVX_RAW, |
| 214 | 215 | CODEC_ID_G2M, |
| 216 | +#endif | |
| 215 | 217 | CODEC_ID_UTVIDEO_DEPRECATED, |
| 216 | 218 | CODEC_ID_UTVIDEO = 0x800, |
| 217 | 219 | |
| @@ -676,8 +678,10 @@ typedef struct RcOverride{ · 458 unmodified lines | ||
| 676 | 678 | /* Codec can export data for HW decoding (XvMC). */ |
| 677 | 679 | #define CODEC_CAP_HWACCEL 0x0010 |
| 678 | 680 | /** |
| 679 | − * Codec has a nonzero delay and needs to be fed with NULL at the end to get the delayed data. | |
| 680 | − * If this is not set, the codec is guaranteed to never be fed with NULL data. | |
| 681 | + * Codec has a nonzero delay and needs to be fed with avpkt->data=NULL, | |
| 682 | + * avpkt->size=0 at the end to get the delayed data until the decoder no longer | |
| 683 | + * returns frames. If this is not set, the codec is guaranteed to never be fed | |
| 684 | + * with NULL data. | |
| 681 | 685 | */ |
| 682 | 686 | #define CODEC_CAP_DELAY 0x0020 |
| 683 | 687 | /** |
| @@ -3608,6 +3612,7 @@ enum PixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum PixelForma · 2924 unmodified lines | ||
| 3608 | 3612 | enum PixelFormat avcodec_find_best_pix_fmt2(enum PixelFormat dst_pix_fmt1, enum PixelFormat dst_pix_fmt2, |
| 3609 | 3613 | enum PixelFormat src_pix_fmt, int has_alpha, int *loss_ptr); |
| 3610 | 3614 | |
| 3615 | +#if FF_API_GET_ALPHA_INFO | |
| 3611 | 3616 | #define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */ |
| 3612 | 3617 | #define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */ |
| 3613 | 3618 | |
| @@ -3615,8 +3620,10 @@ enum PixelFormat avcodec_find_best_pix_fmt2(enum PixelFormat dst_pix_fmt1, enum · 1 unmodified line | ||
| 3615 | 3620 | * Tell if an image really has transparent alpha values. |
| 3616 | 3621 | * @return ored mask of FF_ALPHA_xxx constants |
| 3617 | 3622 | */ |
| 3623 | +attribute_deprecated | |
| 3618 | 3624 | int img_get_alpha_info(const AVPicture *src, |
| 3619 | 3625 | enum PixelFormat pix_fmt, int width, int height); |
| 3626 | +#endif | |
| 3620 | 3627 | |
| 3621 | 3628 | /* deinterlace a picture */ |
| 3622 | 3629 | /* deinterlace - if not supported return -1 */ |
| @@ -3940,6 +3947,10 @@ int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options) · 317 unmodified lines | ||
| 3940 | 3947 | * samples should be 16 byte aligned unless the CPU doesn't need it |
| 3941 | 3948 | * (AltiVec and SSE do). |
| 3942 | 3949 | * |
| 3950 | + * @note Codecs which have the CODEC_CAP_DELAY capability set have a delay | |
| 3951 | + * between input and output, these need to be fed with avpkt->data=NULL, | |
| 3952 | + * avpkt->size=0 at the end to return the remaining frames. | |
| 3953 | + * | |
| 3943 | 3954 | * @param avctx the codec context |
| 3944 | 3955 | * @param[out] samples the output buffer, sample type in avctx->sample_fmt |
| 3945 | 3956 | * @param[in,out] frame_size_ptr the output buffer size in bytes |
| @@ -3973,8 +3984,9 @@ int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, · 27 unmodified lines | ||
| 3973 | 3984 | * |
| 3974 | 3985 | * In practice, avpkt->data should have 4 byte alignment at minimum. |
| 3975 | 3986 | * |
| 3976 | − * @note Some codecs have a delay between input and output, these need to be | |
| 3977 | − * fed with avpkt->data=NULL, avpkt->size=0 at the end to return the remaining frames. | |
| 3987 | + * @note Codecs which have the CODEC_CAP_DELAY capability set have a delay | |
| 3988 | + * between input and output, these need to be fed with avpkt->data=NULL, | |
| 3989 | + * avpkt->size=0 at the end to return the remaining frames. | |
| 3978 | 3990 | * |
| 3979 | 3991 | * @param avctx the codec context |
| 3980 | 3992 | * @param[out] picture The AVFrame in which the decoded video frame will be stored. |
| @@ -41,7 +41,7 @@ const uint8_t ff_log2_run[41]={ · 40 unmodified lines | ||
| 41 | 41 | 24, |
| 42 | 42 | }; |
| 43 | 43 | |
| 44 | −void align_put_bits(PutBitContext *s) | |
| 44 | +void avpriv_align_put_bits(PutBitContext *s) | |
| 45 | 45 | { |
| 46 | 46 | put_bits(s,s->bit_left & 7,0); |
| 47 | 47 | } |
| @@ -56,7 +56,7 @@ void ff_put_string(PutBitContext *pb, const char *string, int terminate_string) · 8 unmodified lines | ||
| 56 | 56 | put_bits(pb, 8, 0); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | −void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length) | |
| 59 | +void avpriv_copy_bits(PutBitContext *pb, const uint8_t *src, int length) | |
| 60 | 60 | { |
| 61 | 61 | int words= length>>4; |
| 62 | 62 | int bits= length&15; |
| @@ -625,8 +625,8 @@ static int decode_seq_header(AVSContext *h) { · 624 unmodified lines | ||
| 625 | 625 | s->low_delay = get_bits1(&s->gb); |
| 626 | 626 | h->mb_width = (s->width + 15) >> 4; |
| 627 | 627 | h->mb_height = (s->height + 15) >> 4; |
| 628 | − h->s.avctx->time_base.den = ff_frame_rate_tab[frame_rate_code].num; | |
| 629 | − h->s.avctx->time_base.num = ff_frame_rate_tab[frame_rate_code].den; | |
| 628 | + h->s.avctx->time_base.den = avpriv_frame_rate_tab[frame_rate_code].num; | |
| 629 | + h->s.avctx->time_base.num = avpriv_frame_rate_tab[frame_rate_code].den; | |
| 630 | 630 | h->s.avctx->width = s->width; |
| 631 | 631 | h->s.avctx->height = s->height; |
| 632 | 632 | if(!h->top_qp) |
| @@ -664,7 +664,7 @@ static int cavs_decode_frame(AVCodecContext * avctx,void *data, int *data_size, · 31 unmodified lines | ||
| 664 | 664 | buf_ptr = buf; |
| 665 | 665 | buf_end = buf + buf_size; |
| 666 | 666 | for(;;) { |
| 667 | − buf_ptr = ff_find_start_code(buf_ptr,buf_end, &stc); | |
| 667 | + buf_ptr = avpriv_mpv_find_start_code(buf_ptr,buf_end, &stc); | |
| 668 | 668 | if((stc & 0xFFFFFE00) || buf_ptr == buf_end) |
| 669 | 669 | return FFMAX(0, buf_ptr - buf - s->parse_context.last_index); |
| 670 | 670 | input_size = (buf_end - buf_ptr)*8; |
| @@ -105,7 +105,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, · 104 unmodified lines | ||
| 105 | 105 | |
| 106 | 106 | emms_c(); |
| 107 | 107 | |
| 108 | − align_put_bits(&a->pb); | |
| 108 | + avpriv_align_put_bits(&a->pb); | |
| 109 | 109 | while(get_bit_count(&a->pb)&31) |
| 110 | 110 | put_bits(&a->pb, 8, 0); |
| 111 | 111 | |
| @@ -145,7 +145,7 @@ static int parse_source_parameters(AVCodecContext *avctx, GetBitContext *gb, · 144 unmodified lines | ||
| 145 | 145 | } |
| 146 | 146 | if (source->frame_rate_index > 0) { |
| 147 | 147 | if (source->frame_rate_index <= 8) |
| 148 | − frame_rate = ff_frame_rate_tab[source->frame_rate_index]; | |
| 148 | + frame_rate = avpriv_frame_rate_tab[source->frame_rate_index]; | |
| 149 | 149 | else |
| 150 | 150 | frame_rate = dirac_frame_rate[source->frame_rate_index-9]; |
| 151 | 151 | } |
| @@ -242,7 +242,7 @@ static int parse_source_parameters(AVCodecContext *avctx, GetBitContext *gb, · 90 unmodified lines | ||
| 242 | 242 | return 0; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | −int ff_dirac_parse_sequence_header(AVCodecContext *avctx, GetBitContext *gb, | |
| 245 | +int avpriv_dirac_parse_sequence_header(AVCodecContext *avctx, GetBitContext *gb, | |
| 246 | 246 | dirac_source_params *source) |
| 247 | 247 | { |
| 248 | 248 | unsigned version_major; |
| @@ -51,7 +51,7 @@ typedef struct { · 50 unmodified lines | ||
| 51 | 51 | uint8_t color_spec_index; ///< index into dirac_color_spec_presets[] |
| 52 | 52 | } dirac_source_params; |
| 53 | 53 | |
| 54 | −int ff_dirac_parse_sequence_header(AVCodecContext *avctx, GetBitContext *gb, | |
| 55 | − dirac_source_params *source); | |
| 54 | +int avpriv_dirac_parse_sequence_header(AVCodecContext *avctx, GetBitContext *gb, | |
| 55 | + dirac_source_params *source); | |
| 56 | 56 | |
| 57 | 57 | #endif /* AVCODEC_DIRAC_H */ |
| @@ -349,7 +349,7 @@ static av_cold int dvvideo_init(AVCodecContext *avctx) · 348 unmodified lines | ||
| 349 | 349 | |
| 350 | 350 | static av_cold int dvvideo_init_encoder(AVCodecContext *avctx) |
| 351 | 351 | { |
| 352 | − if (!ff_dv_codec_profile(avctx)) { | |
| 352 | + if (!avpriv_dv_codec_profile(avctx)) { | |
| 353 | 353 | av_log(avctx, AV_LOG_ERROR, "Found no DV profile for %ix%i %s video\n", |
| 354 | 354 | avctx->width, avctx->height, av_get_pix_fmt_name(avctx->pix_fmt)); |
| 355 | 355 | return -1; |
| @@ -1072,7 +1072,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, · 716 unmodified lines | ||
| 1072 | 1072 | const uint8_t* vsc_pack; |
| 1073 | 1073 | int apt, is16_9; |
| 1074 | 1074 | |
| 1075 | − s->sys = ff_dv_frame_profile2(avctx, s->sys, buf, buf_size); | |
| 1075 | + s->sys = avpriv_dv_frame_profile2(avctx, s->sys, buf, buf_size); | |
| 1076 | 1076 | if (!s->sys || buf_size < s->sys->frame_size || dv_init_dynamic_tables(s->sys)) { |
| 1077 | 1077 | av_log(avctx, AV_LOG_ERROR, "could not find dv frame profile\n"); |
| 1078 | 1078 | return -1; /* NOTE: we only accept several full frames */ |
| @@ -1246,7 +1246,7 @@ static int dvvideo_encode_frame(AVCodecContext *c, uint8_t *buf, int buf_size, · 167 unmodified lines | ||
| 1246 | 1246 | { |
| 1247 | 1247 | DVVideoContext *s = c->priv_data; |
| 1248 | 1248 | |
| 1249 | − s->sys = ff_dv_codec_profile(c); | |
| 1249 | + s->sys = avpriv_dv_codec_profile(c); | |
| 1250 | 1250 | if (!s->sys || buf_size < s->sys->frame_size || dv_init_dynamic_tables(s->sys)) |
| 1251 | 1251 | return -1; |
| 1252 | 1252 | |
| @@ -246,7 +246,7 @@ static const DVprofile dv_profiles[] = { · 245 unmodified lines | ||
| 246 | 246 | } |
| 247 | 247 | }; |
| 248 | 248 | |
| 249 | −const DVprofile* ff_dv_frame_profile2(AVCodecContext* codec, const DVprofile *sys, | |
| 249 | +const DVprofile* avpriv_dv_frame_profile2(AVCodecContext* codec, const DVprofile *sys, | |
| 250 | 250 | const uint8_t* frame, unsigned buf_size) |
| 251 | 251 | { |
| 252 | 252 | int i, dsf, stype; |
| @@ -276,13 +276,13 @@ const DVprofile* ff_dv_frame_profile2(AVCodecContext* codec, const DVprofile *sy · 23 unmodified lines | ||
| 276 | 276 | return NULL; |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | −const DVprofile* ff_dv_frame_profile(const DVprofile *sys, | |
| 279 | +const DVprofile* avpriv_dv_frame_profile(const DVprofile *sys, | |
| 280 | 280 | const uint8_t* frame, unsigned buf_size) |
| 281 | 281 | { |
| 282 | − return ff_dv_frame_profile2(NULL, sys, frame, buf_size); | |
| 282 | + return avpriv_dv_frame_profile2(NULL, sys, frame, buf_size); | |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | −const DVprofile* ff_dv_codec_profile(AVCodecContext* codec) | |
| 285 | +const DVprofile* avpriv_dv_codec_profile(AVCodecContext* codec) | |
| 286 | 286 | { |
| 287 | 287 | int i; |
| 288 | 288 | |
| @@ -274,11 +274,11 @@ enum dv_pack_type { · 273 unmodified lines | ||
| 274 | 274 | */ |
| 275 | 275 | #define DV_MAX_BPM 8 |
| 276 | 276 | |
| 277 | −const DVprofile* ff_dv_frame_profile(const DVprofile *sys, | |
| 277 | +const DVprofile* avpriv_dv_frame_profile(const DVprofile *sys, | |
| 278 | 278 | const uint8_t* frame, unsigned buf_size); |
| 279 | −const DVprofile* ff_dv_frame_profile2(AVCodecContext* codec, const DVprofile *sys, | |
| 279 | +const DVprofile* avpriv_dv_frame_profile2(AVCodecContext* codec, const DVprofile *sys, | |
| 280 | 280 | const uint8_t* frame, unsigned buf_size); |
| 281 | −const DVprofile* ff_dv_codec_profile(AVCodecContext* codec); | |
| 281 | +const DVprofile* avpriv_dv_codec_profile(AVCodecContext* codec); | |
| 282 | 282 | |
| 283 | 283 | static inline int dv_write_dif_id(enum dv_section_type t, uint8_t chan_num, |
| 284 | 284 | uint8_t seq_num, uint8_t dif_num, |
| @@ -95,8 +95,8 @@ typedef struct FLACFrameInfo { · 94 unmodified lines | ||
| 95 | 95 | * @param[out] s where parsed information is stored |
| 96 | 96 | * @param[in] buffer pointer to start of 34-byte streaminfo data |
| 97 | 97 | */ |
| 98 | −void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, | |
| 99 | − const uint8_t *buffer); | |
| 98 | +void avpriv_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, | |
| 99 | + const uint8_t *buffer); | |
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | 102 | * Validate the FLAC extradata. |
| @@ -105,9 +105,9 @@ void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, · 2 unmodified lines | ||
| 105 | 105 | * @param[out] streaminfo_start pointer to start of 34-byte STREAMINFO data. |
| 106 | 106 | * @return 1 if valid, 0 if not valid. |
| 107 | 107 | */ |
| 108 | −int ff_flac_is_extradata_valid(AVCodecContext *avctx, | |
| 109 | − enum FLACExtradataFormat *format, | |
| 110 | − uint8_t **streaminfo_start); | |
| 108 | +int avpriv_flac_is_extradata_valid(AVCodecContext *avctx, | |
| 109 | + enum FLACExtradataFormat *format, | |
| 110 | + uint8_t **streaminfo_start); | |
| 111 | 111 | |
| 112 | 112 | /** |
| 113 | 113 | * Parse the metadata block parameters from the header. |
| @@ -116,8 +116,8 @@ int ff_flac_is_extradata_valid(AVCodecContext *avctx, · 2 unmodified lines | ||
| 116 | 116 | * @param[out] type metadata block type |
| 117 | 117 | * @param[out] size metadata block size |
| 118 | 118 | */ |
| 119 | −void ff_flac_parse_block_header(const uint8_t *block_header, | |
| 120 | − int *last, int *type, int *size); | |
| 119 | +void avpriv_flac_parse_block_header(const uint8_t *block_header, | |
| 120 | + int *last, int *type, int *size); | |
| 121 | 121 | |
| 122 | 122 | /** |
| 123 | 123 | * Calculate an estimate for the maximum frame size based on verbatim mode. |
| @@ -63,7 +63,7 @@ typedef struct FLACContext { · 62 unmodified lines | ||
| 63 | 63 | |
| 64 | 64 | static void allocate_buffers(FLACContext *s); |
| 65 | 65 | |
| 66 | −int ff_flac_is_extradata_valid(AVCodecContext *avctx, | |
| 66 | +int avpriv_flac_is_extradata_valid(AVCodecContext *avctx, | |
| 67 | 67 | enum FLACExtradataFormat *format, |
| 68 | 68 | uint8_t **streaminfo_start) |
| 69 | 69 | { |
| @@ -104,11 +104,11 @@ static av_cold int flac_decode_init(AVCodecContext *avctx) · 34 unmodified lines | ||
| 104 | 104 | if (!avctx->extradata) |
| 105 | 105 | return 0; |
| 106 | 106 | |
| 107 | − if (!ff_flac_is_extradata_valid(avctx, &format, &streaminfo)) | |
| 107 | + if (!avpriv_flac_is_extradata_valid(avctx, &format, &streaminfo)) | |
| 108 | 108 | return -1; |
| 109 | 109 | |
| 110 | 110 | /* initialize based on the demuxer-supplied streamdata header */ |
| 111 | − ff_flac_parse_streaminfo(avctx, (FLACStreaminfo *)s, streaminfo); | |
| 111 | + avpriv_flac_parse_streaminfo(avctx, (FLACStreaminfo *)s, streaminfo); | |
| 112 | 112 | if (s->bps > 16) |
| 113 | 113 | avctx->sample_fmt = AV_SAMPLE_FMT_S32; |
| 114 | 114 | else |
| @@ -140,7 +140,7 @@ static void allocate_buffers(FLACContext *s) · 25 unmodified lines | ||
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | −void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, | |
| 143 | +void avpriv_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, | |
| 144 | 144 | const uint8_t *buffer) |
| 145 | 145 | { |
| 146 | 146 | GetBitContext gb; |
| @@ -174,7 +174,7 @@ void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, · 27 unmodified lines | ||
| 174 | 174 | dump_headers(avctx, s); |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | −void ff_flac_parse_block_header(const uint8_t *block_header, | |
| 177 | +void avpriv_flac_parse_block_header(const uint8_t *block_header, | |
| 178 | 178 | int *last, int *type, int *size) |
| 179 | 179 | { |
| 180 | 180 | int tmp = bytestream_get_byte(&block_header); |
| @@ -201,12 +201,12 @@ static int parse_streaminfo(FLACContext *s, const uint8_t *buf, int buf_size) · 20 unmodified lines | ||
| 201 | 201 | /* need more data */ |
| 202 | 202 | return 0; |
| 203 | 203 | } |
| 204 | − ff_flac_parse_block_header(&buf[4], NULL, &metadata_type, &metadata_size); | |
| 204 | + avpriv_flac_parse_block_header(&buf[4], NULL, &metadata_type, &metadata_size); | |
| 205 | 205 | if (metadata_type != FLAC_METADATA_TYPE_STREAMINFO || |
| 206 | 206 | metadata_size != FLAC_STREAMINFO_SIZE) { |
| 207 | 207 | return AVERROR_INVALIDDATA; |
| 208 | 208 | } |
| 209 | − ff_flac_parse_streaminfo(s->avctx, (FLACStreaminfo *)s, &buf[8]); | |
| 209 | + avpriv_flac_parse_streaminfo(s->avctx, (FLACStreaminfo *)s, &buf[8]); | |
| 210 | 210 | allocate_buffers(s); |
| 211 | 211 | s->got_streaminfo = 1; |
| 212 | 212 | |
| @@ -228,7 +228,7 @@ static int get_metadata_size(const uint8_t *buf, int buf_size) · 15 unmodified lines | ||
| 228 | 228 | do { |
| 229 | 229 | if (buf_end - buf < 4) |
| 230 | 230 | return 0; |
| 231 | − ff_flac_parse_block_header(buf, &metadata_last, NULL, &metadata_size); | |
| 231 | + avpriv_flac_parse_block_header(buf, &metadata_last, NULL, &metadata_size); | |
| 232 | 232 | buf += 4; |
| 233 | 233 | if (buf_end - buf < metadata_size) { |
| 234 | 234 | /* need more data in order to read the complete header */ |
| @@ -25,7 +25,7 @@ void ff_flv_encode_picture_header(MpegEncContext * s, int picture_number) · 24 unmodified lines | ||
| 25 | 25 | { |
| 26 | 26 | int format; |
| 27 | 27 | |
| 28 | − align_put_bits(&s->pb); | |
| 28 | + avpriv_align_put_bits(&s->pb); | |
| 29 | 29 | |
| 30 | 30 | put_bits(&s->pb, 17, 1); |
| 31 | 31 | put_bits(&s->pb, 5, (s->h263_flv-1)); /* 0: h263 escape codes 1: 11-bit escape codes */ |
| @@ -53,7 +53,7 @@ void ff_h261_encode_picture_header(MpegEncContext * s, int picture_number){ · 52 unmodified lines | ||
| 53 | 53 | H261Context * h = (H261Context *) s; |
| 54 | 54 | int format, temp_ref; |
| 55 | 55 | |
| 56 | − align_put_bits(&s->pb); | |
| 56 | + avpriv_align_put_bits(&s->pb); | |
| 57 | 57 | |
| 58 | 58 | /* Update the pointer to last GOB */ |
| 59 | 59 | s->ptr_lastgob = put_bits_ptr(&s->pb); |
| @@ -153,7 +153,7 @@ static inline int parse_nal_units(AVCodecParserContext *s, · 152 unmodified lines | ||
| 153 | 153 | |
| 154 | 154 | for(;;) { |
| 155 | 155 | int src_length, dst_length, consumed; |
| 156 | − buf = ff_find_start_code(buf, buf_end, &state); | |
| 156 | + buf = avpriv_mpv_find_start_code(buf, buf_end, &state); | |
| 157 | 157 | if(buf >= buf_end) |
| 158 | 158 | break; |
| 159 | 159 | --buf; |
| @@ -747,6 +747,7 @@ int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, · 746 unmodified lines | ||
| 747 | 747 | return 0; |
| 748 | 748 | } |
| 749 | 749 | |
| 750 | +#if FF_API_GET_ALPHA_INFO | |
| 750 | 751 | /* NOTE: we scan all the pixels to have an exact information */ |
| 751 | 752 | static int get_alpha_info_pal8(const AVPicture *src, int width, int height) |
| 752 | 753 | { |
| @@ -793,6 +794,7 @@ int img_get_alpha_info(const AVPicture *src, · 40 unmodified lines | ||
| 793 | 794 | } |
| 794 | 795 | return ret; |
| 795 | 796 | } |
| 797 | +#endif | |
| 796 | 798 | |
| 797 | 799 | #if !(HAVE_MMX && HAVE_YASM) |
| 798 | 800 | /* filter parameters: [-1 4 2 4 -1] // 8 */ |
| @@ -53,7 +53,7 @@ AVHWAccel *ff_find_hwaccel(enum CodecID codec_id, enum PixelFormat pix_fmt); · 52 unmodified lines | ||
| 53 | 53 | */ |
| 54 | 54 | int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b); |
| 55 | 55 | |
| 56 | −unsigned int ff_toupper4(unsigned int x); | |
| 56 | +unsigned int avpriv_toupper4(unsigned int x); | |
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * does needed setup of pkt_pts/pos and such for (re)get_buffer(); |
| @@ -126,7 +126,7 @@ void h263_encode_picture_header(MpegEncContext * s, int picture_number) · 125 unmodified lines | ||
| 126 | 126 | coded_frame_rate= 1800000; |
| 127 | 127 | coded_frame_rate_base= (1000+best_clock_code)*best_divisor; |
| 128 | 128 | |
| 129 | − align_put_bits(&s->pb); | |
| 129 | + avpriv_align_put_bits(&s->pb); | |
| 130 | 130 | |
| 131 | 131 | /* Update the pointer to last GOB */ |
| 132 | 132 | s->ptr_lastgob = put_bits_ptr(&s->pb); |
| @@ -357,7 +357,7 @@ static int encode_picture_ls(AVCodecContext *avctx, unsigned char *buf, int buf_ · 356 unmodified lines | ||
| 357 | 357 | put_bits(&pb, 8, v); |
| 358 | 358 | } |
| 359 | 359 | } |
| 360 | − align_put_bits(&pb); | |
| 360 | + avpriv_align_put_bits(&pb); | |
| 361 | 361 | av_free(buf2); |
| 362 | 362 | |
| 363 | 363 | /* End of image */ |
| @@ -1,9 +1,8 @@ | ||
| 1 | 1 | LIBAVCODEC_$MAJOR { |
| 2 | − global: *; | |
| 3 | − local: | |
| 4 | − ff_*_bsf; | |
| 5 | − ff_*_decoder; | |
| 6 | − ff_*_encoder; | |
| 7 | − ff_*_hwaccel; | |
| 8 | − ff_*_parser; | |
| 2 | + global: av*; | |
| 3 | + audio_resample; | |
| 4 | + audio_resample_close; | |
| 5 | + #deprecated, remove after next bump | |
| 6 | + img_get_alpha_info; | |
| 7 | + local: *; | |
| 9 | 8 | }; |
| @@ -1,5 +1,7 @@ | ||
| 1 | 1 | /* |
| 2 | − * Copyright (c) 2009 by Xuggle Incorporated. All rights reserved. | |
| 2 | + * Copyright (C) 2009 Justin Ruggles | |
| 3 | + * Copyright (c) 2009 Xuggle Incorporated | |
| 4 | + * | |
| 3 | 5 | * This file is part of FFmpeg. |
| 4 | 6 | * |
| 5 | 7 | * FFmpeg is free software; you can redistribute it and/or |
| @@ -16,163 +18,307 @@ · 10 unmodified lines | ||
| 16 | 18 | * License along with FFmpeg; if not, write to the Free Software |
| 17 | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | 20 | */ |
| 19 | −#include <libavcodec/avcodec.h> | |
| 21 | + | |
| 22 | +/** | |
| 23 | + * @file | |
| 24 | + * libspeex Speex audio encoder | |
| 25 | + * | |
| 26 | + * Usage Guide | |
| 27 | + * This explains the values that need to be set prior to initialization in | |
| 28 | + * order to control various encoding parameters. | |
| 29 | + * | |
| 30 | + * Channels | |
| 31 | + * Speex only supports mono or stereo, so avctx->channels must be set to | |
| 32 | + * 1 or 2. | |
| 33 | + * | |
| 34 | + * Sample Rate / Encoding Mode | |
| 35 | + * Speex has 3 modes, each of which uses a specific sample rate. | |
| 36 | + * narrowband : 8 kHz | |
| 37 | + * wideband : 16 kHz | |
| 38 | + * ultra-wideband : 32 kHz | |
| 39 | + * avctx->sample_rate must be set to one of these 3 values. This will be | |
| 40 | + * used to set the encoding mode. | |
| 41 | + * | |
| 42 | + * Rate Control | |
| 43 | + * VBR mode is turned on by setting CODEC_FLAG_QSCALE in avctx->flags. | |
| 44 | + * avctx->global_quality is used to set the encoding quality. | |
| 45 | + * For CBR mode, avctx->bit_rate can be used to set the constant bitrate. | |
| 46 | + * Alternatively, the 'cbr_quality' option can be set from 0 to 10 to set | |
| 47 | + * a constant bitrate based on quality. | |
| 48 | + * For ABR mode, set avctx->bit_rate and set the 'abr' option to 1. | |
| 49 | + * Approx. Bitrate Range: | |
| 50 | + * narrowband : 2400 - 25600 bps | |
| 51 | + * wideband : 4000 - 43200 bps | |
| 52 | + * ultra-wideband : 4400 - 45200 bps | |
| 53 | + * | |
| 54 | + * Complexity | |
| 55 | + * Encoding complexity is controlled by setting avctx->compression_level. | |
| 56 | + * The valid range is 0 to 10. A higher setting gives generally better | |
| 57 | + * quality at the expense of encoding speed. This does not affect the | |
| 58 | + * bit rate. | |
| 59 | + * | |
| 60 | + * Frames-per-Packet | |
| 61 | + * The encoder defaults to using 1 frame-per-packet. However, it is | |
| 62 | + * sometimes desirable to use multiple frames-per-packet to reduce the | |
| 63 | + * amount of container overhead. This can be done by setting the | |
| 64 | + * 'frames_per_packet' option to a value 1 to 8. | |
| 65 | + */ | |
| 66 | + | |
| 20 | 67 | #include <speex/speex.h> |
| 21 | 68 | #include <speex/speex_header.h> |
| 22 | 69 | #include <speex/speex_stereo.h> |
| 70 | +#include "libavutil/mathematics.h" | |
| 71 | +#include "libavutil/opt.h" | |
| 72 | +#include "avcodec.h" | |
| 73 | +#include "internal.h" | |
| 23 | 74 | |
| 24 | 75 | typedef struct { |
| 25 | − SpeexBits bits; | |
| 26 | − void *enc_state; | |
| 27 | − SpeexHeader header; | |
| 76 | + AVClass *class; ///< AVClass for private options | |
| 77 | + SpeexBits bits; ///< libspeex bitwriter context | |
| 78 | + SpeexHeader header; ///< libspeex header struct | |
| 79 | + void *enc_state; ///< libspeex encoder state | |
| 80 | + int frames_per_packet; ///< number of frames to encode in each packet | |
| 81 | + float vbr_quality; ///< VBR quality 0.0 to 10.0 | |
| 82 | + int cbr_quality; ///< CBR quality 0 to 10 | |
| 83 | + int abr; ///< flag to enable ABR | |
| 84 | + int pkt_frame_count; ///< frame count for the current packet | |
| 85 | + int lookahead; ///< encoder delay | |
| 86 | + int sample_count; ///< total sample count (used for pts) | |
| 28 | 87 | } LibSpeexEncContext; |
| 29 | 88 | |
| 89 | +static av_cold void print_enc_params(AVCodecContext *avctx, | |
| 90 | + LibSpeexEncContext *s) | |
| 91 | +{ | |
| 92 | + const char *mode_str = "unknown"; | |
| 93 | + | |
| 94 | + av_log(avctx, AV_LOG_DEBUG, "channels: %d\n", avctx->channels); | |
| 95 | + switch (s->header.mode) { | |
| 96 | + case SPEEX_MODEID_NB: mode_str = "narrowband"; break; | |
| 97 | + case SPEEX_MODEID_WB: mode_str = "wideband"; break; | |
| 98 | + case SPEEX_MODEID_UWB: mode_str = "ultra-wideband"; break; | |
| 99 | + } | |
| 100 | + av_log(avctx, AV_LOG_DEBUG, "mode: %s\n", mode_str); | |
| 101 | + if (s->header.vbr) { | |
| 102 | + av_log(avctx, AV_LOG_DEBUG, "rate control: VBR\n"); | |
| 103 | + av_log(avctx, AV_LOG_DEBUG, " quality: %f\n", s->vbr_quality); | |
| 104 | + } else if (s->abr) { | |
| 105 | + av_log(avctx, AV_LOG_DEBUG, "rate control: ABR\n"); | |
| 106 | + av_log(avctx, AV_LOG_DEBUG, " bitrate: %d bps\n", avctx->bit_rate); | |
| 107 | + } else { | |
| 108 | + av_log(avctx, AV_LOG_DEBUG, "rate control: CBR\n"); | |
| 109 | + av_log(avctx, AV_LOG_DEBUG, " bitrate: %d bps\n", avctx->bit_rate); | |
| 110 | + } | |
| 111 | + av_log(avctx, AV_LOG_DEBUG, "complexity: %d\n", | |
| 112 | + avctx->compression_level); | |
| 113 | + av_log(avctx, AV_LOG_DEBUG, "frame size: %d samples\n", | |
| 114 | + avctx->frame_size); | |
| 115 | + av_log(avctx, AV_LOG_DEBUG, "frames per packet: %d\n", | |
| 116 | + s->frames_per_packet); | |
| 117 | + av_log(avctx, AV_LOG_DEBUG, "packet size: %d\n", | |
| 118 | + avctx->frame_size * s->frames_per_packet); | |
| 119 | +} | |
| 30 | 120 | |
| 31 | −static av_cold int libspeex_encode_init(AVCodecContext *avctx) | |
| 121 | +static av_cold int encode_init(AVCodecContext *avctx) | |
| 32 | 122 | { |
| 33 | − LibSpeexEncContext *s = (LibSpeexEncContext*)avctx->priv_data; | |
| 123 | + LibSpeexEncContext *s = avctx->priv_data; | |
| 34 | 124 | const SpeexMode *mode; |
| 125 | + uint8_t *header_data; | |
| 126 | + int header_size; | |
| 127 | + int32_t complexity; | |
| 35 | 128 | |
| 36 | − if ((avctx->sample_fmt != SAMPLE_FMT_S16 && avctx->sample_fmt != SAMPLE_FMT_FLT) || | |
| 37 | − avctx->sample_rate <= 0 || | |
| 38 | − avctx->channels <= 0 || | |
| 39 | − avctx->channels > 2) | |
| 40 | − { | |
| 41 | − av_log(avctx, AV_LOG_ERROR, "Unsupported sample format, rate, or channels for speex"); | |
| 42 | − return -1; | |
| 129 | + /* channels */ | |
| 130 | + if (avctx->channels < 1 || avctx->channels > 2) { | |
| 131 | + av_log(avctx, AV_LOG_ERROR, "Invalid channels (%d). Only stereo and " | |
| 132 | + "mono are supported\n", avctx->channels); | |
| 133 | + return AVERROR(EINVAL); | |
| 43 | 134 | } |
| 44 | 135 | |
| 45 | − if (avctx->sample_rate <= 8000) | |
| 46 | − mode = &speex_nb_mode; | |
| 47 | − else if (avctx->sample_rate <= 16000) | |
| 48 | − mode = &speex_wb_mode; | |
| 49 | − else | |
| 50 | − mode = &speex_uwb_mode; | |
| 136 | + /* sample rate and encoding mode */ | |
| 137 | + switch (avctx->sample_rate) { | |
| 138 | + case 8000: mode = &speex_nb_mode; break; | |
| 139 | + case 16000: mode = &speex_wb_mode; break; | |
| 140 | + case 32000: mode = &speex_uwb_mode; break; | |
| 141 | + default: | |
| 142 | + av_log(avctx, AV_LOG_ERROR, "Sample rate of %d Hz is not supported. " | |
| 143 | + "Resample to 8, 16, or 32 kHz.\n", avctx->sample_rate); | |
| 144 | + return AVERROR(EINVAL); | |
| 145 | + } | |
| 51 | 146 | |
| 52 | − speex_bits_init(&s->bits); | |
| 147 | + /* initialize libspeex */ | |
| 53 | 148 | s->enc_state = speex_encoder_init(mode); |
| 54 | − if (!s->enc_state) | |
| 55 | − { | |
| 56 | − av_log(avctx, AV_LOG_ERROR, "could not initialize speex encoder"); | |
| 149 | + if (!s->enc_state) { | |
| 150 | + av_log(avctx, AV_LOG_ERROR, "Error initializing libspeex\n"); | |
| 57 | 151 | return -1; |
| 58 | 152 | } |
| 153 | + speex_init_header(&s->header, avctx->sample_rate, avctx->channels, mode); | |
| 59 | 154 | |
| 60 | − // initialize the header | |
| 61 | − speex_init_header(&s->header, avctx->sample_rate, | |
| 62 | − avctx->channels, mode); | |
| 63 | − | |
| 64 | − // TODO: It'd be nice to support VBR here, but | |
| 65 | − // I'm uncertain what AVCodecContext options to use | |
| 66 | − // to signal whether to turn it on. | |
| 155 | + /* rate control method and parameters */ | |
| 67 | 156 | if (avctx->flags & CODEC_FLAG_QSCALE) { |
| 68 | − spx_int32_t quality = 0; | |
| 69 | − // Map global_quality's mpeg 1/2/4 scale into Speex's 0-10 scale | |
| 70 | − if (avctx->global_quality > FF_LAMBDA_MAX) | |
| 71 | − quality = 0; // lowest possible quality | |
| 72 | − else | |
| 73 | − quality = (spx_int32_t)((FF_LAMBDA_MAX-avctx->global_quality)*10.0/FF_LAMBDA_MAX); | |
| 74 | − speex_encoder_ctl(s->enc_state, SPEEX_SET_QUALITY, &quality); | |
| 157 | + /* VBR */ | |
| 158 | + s->header.vbr = 1; | |
| 159 | + speex_encoder_ctl(s->enc_state, SPEEX_SET_VBR, &s->header.vbr); | |
| 160 | + s->vbr_quality = av_clipf(avctx->global_quality / (float)FF_QP2LAMBDA, | |
| 161 | + 0.0f, 10.0f); | |
| 162 | + speex_encoder_ctl(s->enc_state, SPEEX_SET_VBR_QUALITY, &s->vbr_quality); | |
| 75 | 163 | } else { |
| 76 | − // default to CBR | |
| 77 | − if (avctx->bit_rate > 0) | |
| 78 | − speex_encoder_ctl(s->enc_state, SPEEX_SET_BITRATE, &avctx->bit_rate); | |
| 79 | − // otherwise just take the default quality setting | |
| 164 | + s->header.bitrate = avctx->bit_rate; | |
| 165 | + if (avctx->bit_rate > 0) { | |
| 166 | + /* CBR or ABR by bitrate */ | |
| 167 | + if (s->abr) { | |
| 168 | + speex_encoder_ctl(s->enc_state, SPEEX_SET_ABR, | |
| 169 | + &s->header.bitrate); | |
| 170 | + speex_encoder_ctl(s->enc_state, SPEEX_GET_ABR, | |
| 171 | + &s->header.bitrate); | |
| 172 | + } else { | |
| 173 | + speex_encoder_ctl(s->enc_state, SPEEX_SET_BITRATE, | |
| 174 | + &s->header.bitrate); | |
| 175 | + speex_encoder_ctl(s->enc_state, SPEEX_GET_BITRATE, | |
| 176 | + &s->header.bitrate); | |
| 177 | + } | |
| 178 | + } else { | |
| 179 | + /* CBR by quality */ | |
| 180 | + speex_encoder_ctl(s->enc_state, SPEEX_SET_QUALITY, | |
| 181 | + &s->cbr_quality); | |
| 182 | + speex_encoder_ctl(s->enc_state, SPEEX_GET_BITRATE, | |
| 183 | + &s->header.bitrate); | |
| 184 | + } | |
| 185 | + /* stereo side information adds about 800 bps to the base bitrate */ | |
| 186 | + /* TODO: this should be calculated exactly */ | |
| 187 | + avctx->bit_rate = s->header.bitrate + (avctx->channels == 2 ? 800 : 0); | |
| 80 | 188 | } |
| 81 | − // reset the bit-rate to the actual bit rate speex will use | |
| 82 | − speex_encoder_ctl(s->enc_state, SPEEX_GET_BITRATE, &s->header.bitrate); | |
| 83 | − avctx->bit_rate = s->header.bitrate; | |
| 84 | − | |
| 85 | − // get the actual sample rate | |
| 86 | − speex_encoder_ctl(s->enc_state, SPEEX_GET_SAMPLING_RATE, &s->header.rate); | |
| 87 | − avctx->sample_rate = s->header.rate; | |
| 88 | − | |
| 89 | − // get the frame-size. To align with FLV, we're going to put 2 frames | |
| 90 | − // per packet. If someone can tell me how to make this configurable | |
| 91 | − // from the avcodec contents, I'll mod this so it's not hard-coded. | |
| 92 | − // but without this, FLV files with speex data won't play correctly | |
| 93 | − // in flash player 10. | |
| 94 | − speex_encoder_ctl(s->enc_state, SPEEX_GET_FRAME_SIZE, &s->header.frame_size); | |
| 95 | − s->header.frames_per_packet = 2; // Need for FLV container support | |
| 96 | − avctx->frame_size = s->header.frame_size*s->header.frames_per_packet; | |
| 97 | − | |
| 98 | − // and we'll put a speex header packet into extradata so that muxers | |
| 99 | − // can use it. | |
| 100 | − avctx->extradata = speex_header_to_packet(&s->header, &avctx->extradata_size); | |
| 189 | + | |
| 190 | + /* set encoding complexity */ | |
| 191 | + if (avctx->compression_level > FF_COMPRESSION_DEFAULT) { | |
| 192 | + complexity = av_clip(avctx->compression_level, 0, 10); | |
| 193 | + speex_encoder_ctl(s->enc_state, SPEEX_SET_COMPLEXITY, &complexity); | |
| 194 | + } | |
| 195 | + speex_encoder_ctl(s->enc_state, SPEEX_GET_COMPLEXITY, &complexity); | |
| 196 | + avctx->compression_level = complexity; | |
| 197 | + | |
| 198 | + /* set packet size */ | |
| 199 | + avctx->frame_size = s->header.frame_size; | |
| 200 | + s->header.frames_per_packet = s->frames_per_packet; | |
| 201 | + | |
| 202 | + /* set encoding delay */ | |
| 203 | + speex_encoder_ctl(s->enc_state, SPEEX_GET_LOOKAHEAD, &s->lookahead); | |
| 204 | + s->sample_count = -s->lookahead; | |
| 205 | + | |
| 206 | + /* create header packet bytes from header struct */ | |
| 207 | + /* note: libspeex allocates the memory for header_data, which is freed | |
| 208 | + below with speex_header_free() */ | |
| 209 | + header_data = speex_header_to_packet(&s->header, &header_size); | |
| 210 | + | |
| 211 | + /* allocate extradata and coded_frame */ | |
| 212 | + avctx->extradata = av_malloc(header_size + FF_INPUT_BUFFER_PADDING_SIZE); | |
| 213 | + avctx->coded_frame = avcodec_alloc_frame(); | |
| 214 | + if (!avctx->extradata || !avctx->coded_frame) { | |
| 215 | + speex_header_free(header_data); | |
| 216 | + speex_encoder_destroy(s->enc_state); | |
| 217 | + av_log(avctx, AV_LOG_ERROR, "memory allocation error\n"); | |
| 218 | + return AVERROR(ENOMEM); | |
| 219 | + } | |
| 220 | + | |
| 221 | + /* copy header packet to extradata */ | |
| 222 | + memcpy(avctx->extradata, header_data, header_size); | |
| 223 | + avctx->extradata_size = header_size; | |
| 224 | + speex_header_free(header_data); | |
| 225 | + | |
| 226 | + /* init libspeex bitwriter */ | |
| 227 | + speex_bits_init(&s->bits); | |
| 228 | + | |
| 229 | + print_enc_params(avctx, s); | |
| 101 | 230 | return 0; |
| 102 | 231 | } |
| 103 | 232 | |
| 104 | −static av_cold int libspeex_encode_frame( | |
| 105 | − AVCodecContext *avctx, uint8_t *frame, | |
| 106 | − int buf_size, void *data) | |
| 233 | +static int encode_frame(AVCodecContext *avctx, uint8_t *frame, int buf_size, | |
| 234 | + void *data) | |
| 107 | 235 | { |
| 108 | − LibSpeexEncContext *s = (LibSpeexEncContext*)avctx->priv_data; | |
| 109 | − int i = 0; | |
| 110 | − | |
| 111 | − if (!data) | |
| 112 | − // nothing to flush | |
| 113 | − return 0; | |
| 114 | − | |
| 115 | − speex_bits_reset(&s->bits); | |
| 116 | − for(i = 0; i < s->header.frames_per_packet; i++) | |
| 117 | − { | |
| 118 | − if (avctx->sample_fmt == SAMPLE_FMT_FLT) | |
| 119 | − { | |
| 120 | − if (avctx->channels == 2) { | |
| 121 | − speex_encode_stereo( | |
| 122 | − (float*)data+i*s->header.frame_size, | |
| 123 | − s->header.frame_size, | |
| 124 | − &s->bits); | |
| 125 | − } | |
| 126 | − speex_encode(s->enc_state, | |
| 127 | − (float*)data+i*s->header.frame_size, &s->bits); | |
| 128 | − } else { | |
| 129 | − if (avctx->channels == 2) { | |
| 130 | − speex_encode_stereo_int( | |
| 131 | − (spx_int16_t*)data+i*s->header.frame_size, | |
| 132 | − s->header.frame_size, | |
| 133 | − &s->bits); | |
| 134 | − } | |
| 135 | − speex_encode_int(s->enc_state, | |
| 136 | − (spx_int16_t*)data+i*s->header.frame_size, &s->bits); | |
| 236 | + LibSpeexEncContext *s = avctx->priv_data; | |
| 237 | + int16_t *samples = data; | |
| 238 | + int sample_count = s->sample_count; | |
| 239 | + | |
| 240 | + if (data) { | |
| 241 | + /* encode Speex frame */ | |
| 242 | + if (avctx->channels == 2) | |
| 243 | + speex_encode_stereo_int(samples, s->header.frame_size, &s->bits); | |
| 244 | + speex_encode_int(s->enc_state, samples, &s->bits); | |
| 245 | + s->pkt_frame_count++; | |
| 246 | + s->sample_count += avctx->frame_size; | |
| 247 | + } else { | |
| 248 | + /* handle end-of-stream */ | |
| 249 | + if (!s->pkt_frame_count) | |
| 250 | + return 0; | |
| 251 | + /* add extra terminator codes for unused frames in last packet */ | |
| 252 | + while (s->pkt_frame_count < s->frames_per_packet) { | |
| 253 | + speex_bits_pack(&s->bits, 15, 5); | |
| 254 | + s->pkt_frame_count++; | |
| 137 | 255 | } |
| 138 | 256 | } |
| 139 | − // put in a terminator so this will fit in a OGG or FLV packet | |
| 140 | − speex_bits_insert_terminator(&s->bits); | |
| 141 | 257 | |
| 142 | − if (buf_size >= speex_bits_nbytes(&s->bits)) { | |
| 143 | − return speex_bits_write(&s->bits, frame, buf_size); | |
| 144 | − } else { | |
| 145 | − av_log(avctx, AV_LOG_ERROR, "output buffer too small"); | |
| 146 | − return -1; | |
| 258 | + /* write output if all frames for the packet have been encoded */ | |
| 259 | + if (s->pkt_frame_count == s->frames_per_packet) { | |
| 260 | + s->pkt_frame_count = 0; | |
| 261 | + avctx->coded_frame->pts = | |
| 262 | + av_rescale_q(sample_count, (AVRational){ 1, avctx->sample_rate }, | |
| 263 | + avctx->time_base); | |
| 264 | + if (buf_size > speex_bits_nbytes(&s->bits)) { | |
| 265 | + int ret = speex_bits_write(&s->bits, frame, buf_size); | |
| 266 | + speex_bits_reset(&s->bits); | |
| 267 | + return ret; | |
| 268 | + } else { | |
| 269 | + av_log(avctx, AV_LOG_ERROR, "output buffer too small"); | |
| 270 | + return AVERROR(EINVAL); | |
| 271 | + } | |
| 147 | 272 | } |
| 273 | + return 0; | |
| 148 | 274 | } |
| 149 | 275 | |
| 150 | −static av_cold int libspeex_encode_close(AVCodecContext *avctx) | |
| 276 | +static av_cold int encode_close(AVCodecContext *avctx) | |
| 151 | 277 | { |
| 152 | − LibSpeexEncContext *s = (LibSpeexEncContext*)avctx->priv_data; | |
| 278 | + LibSpeexEncContext *s = avctx->priv_data; | |
| 153 | 279 | |
| 154 | 280 | speex_bits_destroy(&s->bits); |
| 155 | 281 | speex_encoder_destroy(s->enc_state); |
| 156 | − s->enc_state = 0; | |
| 157 | − if (avctx->extradata) | |
| 158 | − speex_header_free(avctx->extradata); | |
| 159 | − avctx->extradata = 0; | |
| 160 | − avctx->extradata_size = 0; | |
| 282 | + | |
| 283 | + av_freep(&avctx->coded_frame); | |
| 284 | + av_freep(&avctx->extradata); | |
| 161 | 285 | |
| 162 | 286 | return 0; |
| 163 | 287 | } |
| 164 | 288 | |
| 289 | +#define OFFSET(x) offsetof(LibSpeexEncContext, x) | |
| 290 | +#define AE AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM | |
| 291 | +static const AVOption options[] = { | |
| 292 | + { "abr", "Use average bit rate", OFFSET(abr), AV_OPT_TYPE_INT, { 0 }, 0, 1, AE }, | |
| 293 | + { "cbr_quality", "Set quality value (0 to 10) for CBR", OFFSET(cbr_quality), AV_OPT_TYPE_INT, { 8 }, 0, 10, AE }, | |
| 294 | + { "frames_per_packet", "Number of frames to encode in each packet", OFFSET(frames_per_packet), AV_OPT_TYPE_INT, { 1 }, 1, 8, AE }, | |
| 295 | + { NULL }, | |
| 296 | +}; | |
| 297 | + | |
| 298 | +static const AVClass class = { | |
| 299 | + .class_name = "libspeex", | |
| 300 | + .item_name = av_default_item_name, | |
| 301 | + .option = options, | |
| 302 | + .version = LIBAVUTIL_VERSION_INT, | |
| 303 | +}; | |
| 304 | + | |
| 305 | +static const AVCodecDefault defaults[] = { | |
| 306 | + { "b", "0" }, | |
| 307 | + { "compression_level", "3" }, | |
| 308 | + { NULL }, | |
| 309 | +}; | |
| 310 | + | |
| 165 | 311 | AVCodec ff_libspeex_encoder = { |
| 166 | − "libspeex", | |
| 167 | − AVMEDIA_TYPE_AUDIO, | |
| 168 | − CODEC_ID_SPEEX, | |
| 169 | − sizeof(LibSpeexEncContext), | |
| 170 | − libspeex_encode_init, | |
| 171 | − libspeex_encode_frame, | |
| 172 | − libspeex_encode_close, | |
| 173 | − 0, | |
| 174 | − .capabilities = CODEC_CAP_DELAY, | |
| 175 | − .supported_samplerates = (const int[]){8000, 16000, 32000, 0}, | |
| 176 | − .sample_fmts = (enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_FLT,SAMPLE_FMT_NONE}, | |
| 177 | − .long_name = NULL_IF_CONFIG_SMALL("libspeex Speex Encoder"), | |
| 312 | + .name = "libspeex", | |
| 313 | + .type = AVMEDIA_TYPE_AUDIO, | |
| 314 | + .id = CODEC_ID_SPEEX, | |
| 315 | + .priv_data_size = sizeof(LibSpeexEncContext), | |
| 316 | + .init = encode_init, | |
| 317 | + .encode = encode_frame, | |
| 318 | + .close = encode_close, | |
| 319 | + .capabilities = CODEC_CAP_DELAY, | |
| 320 | + .sample_fmts = (const enum SampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, | |
| 321 | + .long_name = NULL_IF_CONFIG_SMALL("libspeex Speex"), | |
| 322 | + .priv_class = &class, | |
| 323 | + .defaults = defaults, | |
| 178 | 324 | }; |
| @@ -63,7 +63,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) · 62 unmodified lines | ||
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | for (index = 0; index < 16; index++) |
| 66 | − if (avctx->sample_rate == ff_mpeg4audio_sample_rates[index]) | |
| 66 | + if (avctx->sample_rate == avpriv_mpeg4audio_sample_rates[index]) | |
| 67 | 67 | break; |
| 68 | 68 | if (index == 16) { |
| 69 | 69 | av_log(avctx, AV_LOG_ERROR, "Unsupported sample rate %d\n", |
| @@ -50,10 +50,10 @@ static int mp3_header_decompress(AVBitStreamFilterContext *bsfc, AVCodecContext · 49 unmodified lines | ||
| 50 | 50 | lsf = sample_rate < (24000+32000)/2; |
| 51 | 51 | mpeg25 = sample_rate < (12000+16000)/2; |
| 52 | 52 | sample_rate_index= (header>>10)&3; |
| 53 | − sample_rate= ff_mpa_freq_tab[sample_rate_index] >> (lsf + mpeg25); //in case sample rate is a little off | |
| 53 | + sample_rate= avpriv_mpa_freq_tab[sample_rate_index] >> (lsf + mpeg25); //in case sample rate is a little off | |
| 54 | 54 | |
| 55 | 55 | for(bitrate_index=2; bitrate_index<30; bitrate_index++){ |
| 56 | − frame_size = ff_mpa_bitrate_tab[lsf][2][bitrate_index>>1]; | |
| 56 | + frame_size = avpriv_mpa_bitrate_tab[lsf][2][bitrate_index>>1]; | |
| 57 | 57 | frame_size = (frame_size * 144000) / (sample_rate << lsf) + (bitrate_index&1); |
| 58 | 58 | if(frame_size == buf_size + 4) |
| 59 | 59 | break; |
| @@ -1290,8 +1290,8 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) · 1289 unmodified lines | ||
| 1290 | 1290 | assert((avctx->sub_id == 1) == (avctx->codec_id == CODEC_ID_MPEG1VIDEO)); |
| 1291 | 1291 | if (avctx->codec_id == CODEC_ID_MPEG1VIDEO) { |
| 1292 | 1292 | //MPEG-1 fps |
| 1293 | − avctx->time_base.den = ff_frame_rate_tab[s->frame_rate_index].num; | |
| 1294 | − avctx->time_base.num = ff_frame_rate_tab[s->frame_rate_index].den; | |
| 1293 | + avctx->time_base.den = avpriv_frame_rate_tab[s->frame_rate_index].num; | |
| 1294 | + avctx->time_base.num = avpriv_frame_rate_tab[s->frame_rate_index].den; | |
| 1295 | 1295 | //MPEG-1 aspect |
| 1296 | 1296 | avctx->sample_aspect_ratio = av_d2q(1.0/ff_mpeg1_aspect[s->aspect_ratio_info], 255); |
| 1297 | 1297 | avctx->ticks_per_frame=1; |
| @@ -1299,8 +1299,8 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) · 1 unmodified line | ||
| 1299 | 1299 | //MPEG-2 fps |
| 1300 | 1300 | av_reduce(&s->avctx->time_base.den, |
| 1301 | 1301 | &s->avctx->time_base.num, |
| 1302 | − ff_frame_rate_tab[s->frame_rate_index].num * s1->frame_rate_ext.num*2, | |
| 1303 | − ff_frame_rate_tab[s->frame_rate_index].den * s1->frame_rate_ext.den, | |
| 1302 | + avpriv_frame_rate_tab[s->frame_rate_index].num * s1->frame_rate_ext.num*2, | |
| 1303 | + avpriv_frame_rate_tab[s->frame_rate_index].den * s1->frame_rate_ext.den, | |
| 1304 | 1304 | 1 << 30); |
| 1305 | 1305 | avctx->ticks_per_frame = 2; |
| 1306 | 1306 | //MPEG-2 aspect |
| @@ -1732,7 +1732,7 @@ static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y, · 425 unmodified lines | ||
| 1732 | 1732 | if (avctx->hwaccel) { |
| 1733 | 1733 | const uint8_t *buf_end, *buf_start = *buf - 4; /* include start_code */ |
| 1734 | 1734 | int start_code = -1; |
| 1735 | − buf_end = ff_find_start_code(buf_start + 2, *buf + buf_size, &start_code); | |
| 1735 | + buf_end = avpriv_mpv_find_start_code(buf_start + 2, *buf + buf_size, &start_code); | |
| 1736 | 1736 | if (buf_end < *buf + buf_size) |
| 1737 | 1737 | buf_end -= 4; |
| 1738 | 1738 | s->mb_y = mb_y; |
| @@ -1923,7 +1923,7 @@ static int slice_decode_thread(AVCodecContext *c, void *arg) · 184 unmodified lines | ||
| 1923 | 1923 | return 0; |
| 1924 | 1924 | |
| 1925 | 1925 | start_code = -1; |
| 1926 | − buf = ff_find_start_code(buf, s->gb.buffer_end, &start_code); | |
| 1926 | + buf = avpriv_mpv_find_start_code(buf, s->gb.buffer_end, &start_code); | |
| 1927 | 1927 | mb_y= (start_code - SLICE_MIN_START_CODE) << field_pic; |
| 1928 | 1928 | if (s->picture_structure == PICT_BOTTOM_FIELD) |
| 1929 | 1929 | mb_y++; |
| @@ -2217,7 +2217,7 @@ int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size, · 287 unmodified lines | ||
| 2217 | 2217 | } |
| 2218 | 2218 | state++; |
| 2219 | 2219 | } else { |
| 2220 | − i = ff_find_start_code(buf + i, buf + buf_size, &state) - buf - 1; | |
| 2220 | + i = avpriv_mpv_find_start_code(buf + i, buf + buf_size, &state) - buf - 1; | |
| 2221 | 2221 | if (pc->frame_start_found == 0 && state >= SLICE_MIN_START_CODE && state <= SLICE_MAX_START_CODE) { |
| 2222 | 2222 | i++; |
| 2223 | 2223 | pc->frame_start_found = 4; |
| @@ -2308,7 +2308,7 @@ static int decode_chunks(AVCodecContext *avctx, · 84 unmodified lines | ||
| 2308 | 2308 | for (;;) { |
| 2309 | 2309 | /* find next start code */ |
| 2310 | 2310 | uint32_t start_code = -1; |
| 2311 | − buf_ptr = ff_find_start_code(buf_ptr, buf_end, &start_code); | |
| 2311 | + buf_ptr = avpriv_mpv_find_start_code(buf_ptr, buf_end, &start_code); | |
| 2312 | 2312 | if (start_code > 0x1ff) { |
| 2313 | 2313 | if (s2->pict_type != AV_PICTURE_TYPE_B || avctx->skip_frame <= AVDISCARD_DEFAULT) { |
| 2314 | 2314 | if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_SLICE)) { |
| @@ -305,7 +305,7 @@ const uint8_t ff_mpeg12_mbMotionVectorTable[17][2] = { · 304 unmodified lines | ||
| 305 | 305 | { 0xc, 10 }, |
| 306 | 306 | }; |
| 307 | 307 | |
| 308 | −const AVRational ff_frame_rate_tab[] = { | |
| 308 | +const AVRational avpriv_frame_rate_tab[] = { | |
| 309 | 309 | { 0, 0}, |
| 310 | 310 | {24000, 1001}, |
| 311 | 311 | { 24, 1}, |
| @@ -48,7 +48,7 @@ extern const uint8_t ff_mpeg12_mbPatTable[64][2]; · 47 unmodified lines | ||
| 48 | 48 | |
| 49 | 49 | extern const uint8_t ff_mpeg12_mbMotionVectorTable[17][2]; |
| 50 | 50 | |
| 51 | −extern const AVRational ff_frame_rate_tab[]; | |
| 51 | +extern const AVRational avpriv_frame_rate_tab[]; | |
| 52 | 52 | |
| 53 | 53 | extern const float ff_mpeg1_aspect[16]; |
| 54 | 54 | extern const AVRational ff_mpeg2_aspect[16]; |
| @@ -121,7 +121,7 @@ static int find_frame_rate_index(MpegEncContext *s){ · 120 unmodified lines | ||
| 121 | 121 | int64_t d; |
| 122 | 122 | |
| 123 | 123 | for(i=1;i<14;i++) { |
| 124 | − int64_t n0= 1001LL/ff_frame_rate_tab[i].den*ff_frame_rate_tab[i].num*s->avctx->time_base.num; | |
| 124 | + int64_t n0= 1001LL/avpriv_frame_rate_tab[i].den*avpriv_frame_rate_tab[i].num*s->avctx->time_base.num; | |
| 125 | 125 | int64_t n1= 1001LL*s->avctx->time_base.den; |
| 126 | 126 | if(s->avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL && i>=9) break; |
| 127 | 127 | |
| @@ -200,7 +200,7 @@ static av_cold int encode_init(AVCodecContext *avctx) · 72 unmodified lines | ||
| 200 | 200 | |
| 201 | 201 | static void put_header(MpegEncContext *s, int header) |
| 202 | 202 | { |
| 203 | − align_put_bits(&s->pb); | |
| 203 | + avpriv_align_put_bits(&s->pb); | |
| 204 | 204 | put_bits(&s->pb, 16, header>>16); |
| 205 | 205 | put_sbits(&s->pb, 16, header); |
| 206 | 206 | } |
| @@ -219,7 +219,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s) · 12 unmodified lines | ||
| 219 | 219 | if(aspect_ratio==0.0) aspect_ratio= 1.0; //pixel aspect 1:1 (VGA) |
| 220 | 220 | |
| 221 | 221 | if (s->current_picture.f.key_frame) { |
| 222 | − AVRational framerate= ff_frame_rate_tab[s->frame_rate_index]; | |
| 222 | + AVRational framerate= avpriv_frame_rate_tab[s->frame_rate_index]; | |
| 223 | 223 | |
| 224 | 224 | /* mpeg1 header repeated every gop */ |
| 225 | 225 | put_header(s, SEQ_START_CODE); |
| @@ -978,7 +978,7 @@ AVCodec ff_mpeg1video_encoder = { · 752 unmodified lines | ||
| 978 | 978 | .init = encode_init, |
| 979 | 979 | .encode = MPV_encode_picture, |
| 980 | 980 | .close = MPV_encode_end, |
| 981 | − .supported_framerates= ff_frame_rate_tab+1, | |
| 981 | + .supported_framerates= avpriv_frame_rate_tab+1, | |
| 982 | 982 | .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, |
| 983 | 983 | .capabilities= CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, |
| 984 | 984 | .long_name= NULL_IF_CONFIG_SMALL("MPEG-1 video"), |
| @@ -993,7 +993,7 @@ AVCodec ff_mpeg2video_encoder = { · 8 unmodified lines | ||
| 993 | 993 | .init = encode_init, |
| 994 | 994 | .encode = MPV_encode_picture, |
| 995 | 995 | .close = MPV_encode_end, |
| 996 | − .supported_framerates= ff_frame_rate_tab+1, | |
| 996 | + .supported_framerates= avpriv_frame_rate_tab+1, | |
| 997 | 997 | .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_NONE}, |
| 998 | 998 | .capabilities= CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, |
| 999 | 999 | .long_name= NULL_IF_CONFIG_SMALL("MPEG-2 video"), |
| @@ -52,7 +52,7 @@ static int parse_config_ALS(GetBitContext *gb, MPEG4AudioConfig *c) · 51 unmodified lines | ||
| 52 | 52 | return 0; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | −const int ff_mpeg4audio_sample_rates[16] = { | |
| 55 | +const int avpriv_mpeg4audio_sample_rates[16] = { | |
| 56 | 56 | 96000, 88200, 64000, 48000, 44100, 32000, |
| 57 | 57 | 24000, 22050, 16000, 12000, 11025, 8000, 7350 |
| 58 | 58 | }; |
| @@ -73,10 +73,10 @@ static inline int get_sample_rate(GetBitContext *gb, int *index) · 14 unmodified lines | ||
| 73 | 73 | { |
| 74 | 74 | *index = get_bits(gb, 4); |
| 75 | 75 | return *index == 0x0f ? get_bits(gb, 24) : |
| 76 | − ff_mpeg4audio_sample_rates[*index]; | |
| 76 | + avpriv_mpeg4audio_sample_rates[*index]; | |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | −int ff_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int buf_size) | |
| 79 | +int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int buf_size) | |
| 80 | 80 | { |
| 81 | 81 | GetBitContext gb; |
| 82 | 82 | int specific_config_bitindex; |
| @@ -151,7 +151,7 @@ static av_always_inline unsigned int copy_bits(PutBitContext *pb, · 68 unmodified lines | ||
| 151 | 151 | return el; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | −int ff_copy_pce_data(PutBitContext *pb, GetBitContext *gb) | |
| 154 | +int avpriv_copy_pce_data(PutBitContext *pb, GetBitContext *gb) | |
| 155 | 155 | { |
| 156 | 156 | int five_bit_ch, four_bit_ch, comment_size, bits; |
| 157 | 157 | int offset = put_bits_count(pb); |
| @@ -173,7 +173,7 @@ int ff_copy_pce_data(PutBitContext *pb, GetBitContext *gb) · 15 unmodified lines | ||
| 173 | 173 | copy_bits(pb, gb, 16); |
| 174 | 174 | if (bits) |
| 175 | 175 | copy_bits(pb, gb, bits); |
| 176 | − align_put_bits(pb); | |
| 176 | + avpriv_align_put_bits(pb); | |
| 177 | 177 | align_get_bits(gb); |
| 178 | 178 | comment_size = copy_bits(pb, gb, 8); |
| 179 | 179 | for (; comment_size > 0; comment_size--) |
| @@ -40,7 +40,7 @@ typedef struct { · 39 unmodified lines | ||
| 40 | 40 | int ps; ///< -1 implicit, 1 presence |
| 41 | 41 | } MPEG4AudioConfig; |
| 42 | 42 | |
| 43 | −extern const int ff_mpeg4audio_sample_rates[16]; | |
| 43 | +extern const int avpriv_mpeg4audio_sample_rates[16]; | |
| 44 | 44 | extern const uint8_t ff_mpeg4audio_channels[8]; |
| 45 | 45 | /** |
| 46 | 46 | * Parse MPEG-4 systems extradata to retrieve audio configuration. |
| @@ -49,7 +49,7 @@ extern const uint8_t ff_mpeg4audio_channels[8]; · 2 unmodified lines | ||
| 49 | 49 | * @param[in] buf_size Extradata size. |
| 50 | 50 | * @return On error -1 is returned, on success AudioSpecificConfig bit index in extradata. |
| 51 | 51 | */ |
| 52 | −int ff_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int buf_size); | |
| 52 | +int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int buf_size); | |
| 53 | 53 | |
| 54 | 54 | enum AudioObjectType { |
| 55 | 55 | AOT_NULL, |
| @@ -101,6 +101,6 @@ enum AudioObjectType { · 45 unmodified lines | ||
| 101 | 101 | #define MAX_PCE_SIZE 304 ///<Maximum size of a PCE including the 3-bit ID_PCE |
| 102 | 102 | ///<marker and the comment |
| 103 | 103 | |
| 104 | −int ff_copy_pce_data(PutBitContext *pb, GetBitContext *gb); | |
| 104 | +int avpriv_copy_pce_data(PutBitContext *pb, GetBitContext *gb); | |
| 105 | 105 | |
| 106 | 106 | #endif /* AVCODEC_MPEG4AUDIO_H */ |
| @@ -1268,8 +1268,8 @@ void ff_mpeg4_merge_partitions(MpegEncContext *s) · 1267 unmodified lines | ||
| 1268 | 1268 | flush_put_bits(&s->tex_pb); |
| 1269 | 1269 | |
| 1270 | 1270 | set_put_bits_buffer_size(&s->pb, s->pb2.buf_end - s->pb.buf); |
| 1271 | − ff_copy_bits(&s->pb, s->pb2.buf , pb2_len); | |
| 1272 | − ff_copy_bits(&s->pb, s->tex_pb.buf, tex_pb_len); | |
| 1271 | + avpriv_copy_bits(&s->pb, s->pb2.buf , pb2_len); | |
| 1272 | + avpriv_copy_bits(&s->pb, s->tex_pb.buf, tex_pb_len); | |
| 1273 | 1273 | s->last_bits= put_bits_count(&s->pb); |
| 1274 | 1274 | } |
| 1275 | 1275 | |
| @@ -64,7 +64,7 @@ static int mpegaudio_parse(AVCodecParserContext *s1, · 63 unmodified lines | ||
| 64 | 64 | |
| 65 | 65 | state= (state<<8) + buf[i++]; |
| 66 | 66 | |
| 67 | − ret = ff_mpa_decode_header(avctx, state, &sr, &channels, &frame_size, &bit_rate); | |
| 67 | + ret = avpriv_mpa_decode_header(avctx, state, &sr, &channels, &frame_size, &bit_rate); | |
| 68 | 68 | if (ret < 4) { |
| 69 | 69 | if(i > 4) |
| 70 | 70 | s->header_count= -2; |
| @@ -27,7 +27,7 @@ · 26 unmodified lines | ||
| 27 | 27 | #include "mpegaudiodata.h" |
| 28 | 28 | |
| 29 | 29 | |
| 30 | −const uint16_t ff_mpa_bitrate_tab[2][3][15] = { | |
| 30 | +const uint16_t avpriv_mpa_bitrate_tab[2][3][15] = { | |
| 31 | 31 | { {0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448 }, |
| 32 | 32 | {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384 }, |
| 33 | 33 | {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 } }, |
| @@ -37,7 +37,7 @@ const uint16_t ff_mpa_bitrate_tab[2][3][15] = { · 3 unmodified lines | ||
| 37 | 37 | } |
| 38 | 38 | }; |
| 39 | 39 | |
| 40 | −const uint16_t ff_mpa_freq_tab[3] = { 44100, 48000, 32000 }; | |
| 40 | +const uint16_t avpriv_mpa_freq_tab[3] = { 44100, 48000, 32000 }; | |
| 41 | 41 | |
| 42 | 42 | /*******************************************************/ |
| 43 | 43 | /* half mpeg encoding window (full precision) */ |
| @@ -32,8 +32,8 @@ · 31 unmodified lines | ||
| 32 | 32 | #define MODE_EXT_MS_STEREO 2 |
| 33 | 33 | #define MODE_EXT_I_STEREO 1 |
| 34 | 34 | |
| 35 | −extern const uint16_t ff_mpa_bitrate_tab[2][3][15]; | |
| 36 | −extern const uint16_t ff_mpa_freq_tab[3]; | |
| 35 | +extern const uint16_t avpriv_mpa_bitrate_tab[2][3][15]; | |
| 36 | +extern const uint16_t avpriv_mpa_freq_tab[3]; | |
| 37 | 37 | extern const int32_t ff_mpa_enwindow[257]; |
| 38 | 38 | extern const int ff_mpa_sblimit_table[5]; |
| 39 | 39 | extern const int ff_mpa_quant_steps[17]; |
| @@ -1789,7 +1789,7 @@ static int decode_frame(AVCodecContext * avctx, · 1788 unmodified lines | ||
| 1789 | 1789 | return -1; |
| 1790 | 1790 | } |
| 1791 | 1791 | |
| 1792 | − if (ff_mpegaudio_decode_header((MPADecodeHeader *)s, header) == 1) { | |
| 1792 | + if (avpriv_mpegaudio_decode_header((MPADecodeHeader *)s, header) == 1) { | |
| 1793 | 1793 | /* free format: prepare to compute frame size */ |
| 1794 | 1794 | s->frame_size = -1; |
| 1795 | 1795 | return -1; |
| @@ -1862,7 +1862,7 @@ static int decode_frame_adu(AVCodecContext * avctx, · 66 unmodified lines | ||
| 1862 | 1862 | return buf_size; |
| 1863 | 1863 | } |
| 1864 | 1864 | |
| 1865 | − ff_mpegaudio_decode_header((MPADecodeHeader *)s, header); | |
| 1865 | + avpriv_mpegaudio_decode_header((MPADecodeHeader *)s, header); | |
| 1866 | 1866 | /* update codec info */ |
| 1867 | 1867 | avctx->sample_rate = s->sample_rate; |
| 1868 | 1868 | avctx->channels = s->nb_channels; |
| @@ -1923,7 +1923,7 @@ static int decode_init_mp3on4(AVCodecContext * avctx) · 54 unmodified lines | ||
| 1923 | 1923 | return -1; |
| 1924 | 1924 | } |
| 1925 | 1925 | |
| 1926 | − ff_mpeg4audio_get_config(&cfg, avctx->extradata, avctx->extradata_size); | |
| 1926 | + avpriv_mpeg4audio_get_config(&cfg, avctx->extradata, avctx->extradata_size); | |
| 1927 | 1927 | if (!cfg.chan_config || cfg.chan_config > 7) { |
| 1928 | 1928 | av_log(avctx, AV_LOG_ERROR, "Invalid channel config number.\n"); |
| 1929 | 1929 | return -1; |
| @@ -2015,7 +2015,7 @@ static int decode_frame_mp3on4(AVCodecContext * avctx, · 85 unmodified lines | ||
| 2015 | 2015 | if (ff_mpa_check_header(header) < 0) // Bad header, discard block |
| 2016 | 2016 | break; |
| 2017 | 2017 | |
| 2018 | − ff_mpegaudio_decode_header((MPADecodeHeader *)m, header); | |
| 2018 | + avpriv_mpegaudio_decode_header((MPADecodeHeader *)m, header); | |
| 2019 | 2019 | out_size += mp_decode_frame(m, outptr, buf, fsize); |
| 2020 | 2020 | buf += fsize; |
| 2021 | 2021 | len -= fsize; |
| @@ -31,7 +31,7 @@ · 30 unmodified lines | ||
| 31 | 31 | #include "mpegaudiodecheader.h" |
| 32 | 32 | |
| 33 | 33 | |
| 34 | −int ff_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header) | |
| 34 | +int avpriv_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header) | |
| 35 | 35 | { |
| 36 | 36 | int sample_rate, frame_size, mpeg25, padding; |
| 37 | 37 | int sample_rate_index, bitrate_index; |
| @@ -46,7 +46,7 @@ int ff_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header) · 8 unmodified lines | ||
| 46 | 46 | s->layer = 4 - ((header >> 17) & 3); |
| 47 | 47 | /* extract frequency */ |
| 48 | 48 | sample_rate_index = (header >> 10) & 3; |
| 49 | − sample_rate = ff_mpa_freq_tab[sample_rate_index] >> (s->lsf + mpeg25); | |
| 49 | + sample_rate = avpriv_mpa_freq_tab[sample_rate_index] >> (s->lsf + mpeg25); | |
| 50 | 50 | sample_rate_index += 3 * (s->lsf + mpeg25); |
| 51 | 51 | s->sample_rate_index = sample_rate_index; |
| 52 | 52 | s->error_protection = ((header >> 16) & 1) ^ 1; |
| @@ -67,7 +67,7 @@ int ff_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header) · 14 unmodified lines | ||
| 67 | 67 | s->nb_channels = 2; |
| 68 | 68 | |
| 69 | 69 | if (bitrate_index != 0) { |
| 70 | − frame_size = ff_mpa_bitrate_tab[s->lsf][s->layer - 1][bitrate_index]; | |
| 70 | + frame_size = avpriv_mpa_bitrate_tab[s->lsf][s->layer - 1][bitrate_index]; | |
| 71 | 71 | s->bit_rate = frame_size * 1000; |
| 72 | 72 | switch(s->layer) { |
| 73 | 73 | case 1: |
| @@ -109,14 +109,14 @@ int ff_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header) · 35 unmodified lines | ||
| 109 | 109 | return 0; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | −int ff_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bit_rate) | |
| 112 | +int avpriv_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bit_rate) | |
| 113 | 113 | { |
| 114 | 114 | MPADecodeHeader s1, *s = &s1; |
| 115 | 115 | |
| 116 | 116 | if (ff_mpa_check_header(head) != 0) |
| 117 | 117 | return -1; |
| 118 | 118 | |
| 119 | − if (ff_mpegaudio_decode_header(s, head) != 0) { | |
| 119 | + if (avpriv_mpegaudio_decode_header(s, head) != 0) { | |
| 120 | 120 | return -1; |
| 121 | 121 | } |
| 122 | 122 | |
| @@ -50,11 +50,11 @@ typedef struct MPADecodeHeader { · 49 unmodified lines | ||
| 50 | 50 | /* header decoding. MUST check the header before because no |
| 51 | 51 | consistency check is done there. Return 1 if free format found and |
| 52 | 52 | that the frame size must be computed externally */ |
| 53 | −int ff_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header); | |
| 53 | +int avpriv_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header); | |
| 54 | 54 | |
| 55 | 55 | /* useful helper to get mpeg audio stream infos. Return -1 if error in |
| 56 | 56 | header, otherwise the coded frame size in bytes */ |
| 57 | −int ff_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bitrate); | |
| 57 | +int avpriv_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bitrate); | |
| 58 | 58 | |
| 59 | 59 | /* fast header check for resync */ |
| 60 | 60 | static inline int ff_mpa_check_header(uint32_t header){ |
| @@ -84,9 +84,9 @@ static av_cold int MPA_encode_init(AVCodecContext *avctx) · 83 unmodified lines | ||
| 84 | 84 | /* encoding freq */ |
| 85 | 85 | s->lsf = 0; |
| 86 | 86 | for(i=0;i<3;i++) { |
| 87 | − if (ff_mpa_freq_tab[i] == freq) | |
| 87 | + if (avpriv_mpa_freq_tab[i] == freq) | |
| 88 | 88 | break; |
| 89 | − if ((ff_mpa_freq_tab[i] / 2) == freq) { | |
| 89 | + if ((avpriv_mpa_freq_tab[i] / 2) == freq) { | |
| 90 | 90 | s->lsf = 1; |
| 91 | 91 | break; |
| 92 | 92 | } |
| @@ -99,7 +99,7 @@ static av_cold int MPA_encode_init(AVCodecContext *avctx) · 6 unmodified lines | ||
| 99 | 99 | |
| 100 | 100 | /* encoding bitrate & frequency */ |
| 101 | 101 | for(i=0;i<15;i++) { |
| 102 | − if (ff_mpa_bitrate_tab[s->lsf][1][i] == bitrate) | |
| 102 | + if (avpriv_mpa_bitrate_tab[s->lsf][1][i] == bitrate) | |
| 103 | 103 | break; |
| 104 | 104 | } |
| 105 | 105 | if (i == 15){ |
| @@ -122,7 +122,7 @@ const enum PixelFormat ff_hwaccel_pixfmt_list_420[] = { · 121 unmodified lines | ||
| 122 | 122 | PIX_FMT_NONE |
| 123 | 123 | }; |
| 124 | 124 | |
| 125 | −const uint8_t *ff_find_start_code(const uint8_t * restrict p, const uint8_t *end, uint32_t * restrict state){ | |
| 125 | +const uint8_t *avpriv_mpv_find_start_code(const uint8_t * restrict p, const uint8_t *end, uint32_t * restrict state){ | |
| 126 | 126 | int i; |
| 127 | 127 | |
| 128 | 128 | assert(p<=end); |
| @@ -645,9 +645,8 @@ av_cold int MPV_common_init(MpegEncContext *s) · 516 unmodified lines | ||
| 645 | 645 | yc_size = y_size + 2 * c_size; |
| 646 | 646 | |
| 647 | 647 | /* convert fourcc to upper case */ |
| 648 | − s->codec_tag = ff_toupper4(s->avctx->codec_tag); | |
| 649 | − | |
| 650 | − s->stream_codec_tag = ff_toupper4(s->avctx->stream_codec_tag); | |
| 648 | + s->codec_tag = avpriv_toupper4(s->avctx->codec_tag); | |
| 649 | + s->stream_codec_tag = avpriv_toupper4(s->avctx->stream_codec_tag); | |
| 651 | 650 | |
| 652 | 651 | s->avctx->coded_frame= (AVFrame*)&s->current_picture; |
| 653 | 652 | |
| @@ -725,7 +725,7 @@ void ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src); · 724 unmodified lines | ||
| 725 | 725 | int MPV_lowest_referenced_row(MpegEncContext *s, int dir); |
| 726 | 726 | void MPV_report_decode_progress(MpegEncContext *s); |
| 727 | 727 | int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src); |
| 728 | −const uint8_t *ff_find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state); | |
| 728 | +const uint8_t *avpriv_mpv_find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state); | |
| 729 | 729 | void ff_set_qscale(MpegEncContext * s, int qscale); |
| 730 | 730 | |
| 731 | 731 | void ff_er_frame_start(MpegEncContext *s); |
| @@ -2051,7 +2051,7 @@ static void write_slice_end(MpegEncContext *s){ · 2050 unmodified lines | ||
| 2051 | 2051 | ff_mjpeg_encode_stuffing(&s->pb); |
| 2052 | 2052 | } |
| 2053 | 2053 | |
| 2054 | − align_put_bits(&s->pb); | |
| 2054 | + avpriv_align_put_bits(&s->pb); | |
| 2055 | 2055 | flush_put_bits(&s->pb); |
| 2056 | 2056 | |
| 2057 | 2057 | if((s->flags&CODEC_FLAG_PASS1) && !s->partitioned_frame) |
| @@ -2492,18 +2492,18 @@ static int encode_thread(AVCodecContext *c, void *arg){ · 434 unmodified lines | ||
| 2492 | 2492 | |
| 2493 | 2493 | pb_bits_count= put_bits_count(&s->pb); |
| 2494 | 2494 | flush_put_bits(&s->pb); |
| 2495 | − ff_copy_bits(&backup_s.pb, bit_buf[next_block^1], pb_bits_count); | |
| 2495 | + avpriv_copy_bits(&backup_s.pb, bit_buf[next_block^1], pb_bits_count); | |
| 2496 | 2496 | s->pb= backup_s.pb; |
| 2497 | 2497 | |
| 2498 | 2498 | if(s->data_partitioning){ |
| 2499 | 2499 | pb2_bits_count= put_bits_count(&s->pb2); |
| 2500 | 2500 | flush_put_bits(&s->pb2); |
| 2501 | − ff_copy_bits(&backup_s.pb2, bit_buf2[next_block^1], pb2_bits_count); | |
| 2501 | + avpriv_copy_bits(&backup_s.pb2, bit_buf2[next_block^1], pb2_bits_count); | |
| 2502 | 2502 | s->pb2= backup_s.pb2; |
| 2503 | 2503 | |
| 2504 | 2504 | tex_pb_bits_count= put_bits_count(&s->tex_pb); |
| 2505 | 2505 | flush_put_bits(&s->tex_pb); |
| 2506 | − ff_copy_bits(&backup_s.tex_pb, bit_buf_tex[next_block^1], tex_pb_bits_count); | |
| 2506 | + avpriv_copy_bits(&backup_s.tex_pb, bit_buf_tex[next_block^1], tex_pb_bits_count); | |
| 2507 | 2507 | s->tex_pb= backup_s.tex_pb; |
| 2508 | 2508 | } |
| 2509 | 2509 | s->last_bits= put_bits_count(&s->pb); |
| @@ -2726,7 +2726,7 @@ static void merge_context_after_encode(MpegEncContext *dst, MpegEncContext *src) · 216 unmodified lines | ||
| 2726 | 2726 | |
| 2727 | 2727 | assert(put_bits_count(&src->pb) % 8 ==0); |
| 2728 | 2728 | assert(put_bits_count(&dst->pb) % 8 ==0); |
| 2729 | − ff_copy_bits(&dst->pb, src->pb.buf, put_bits_count(&src->pb)); | |
| 2729 | + avpriv_copy_bits(&dst->pb, src->pb.buf, put_bits_count(&src->pb)); | |
| 2730 | 2730 | flush_put_bits(&dst->pb); |
| 2731 | 2731 | } |
| 2732 | 2732 | |
| @@ -40,7 +40,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, · 39 unmodified lines | ||
| 40 | 40 | |
| 41 | 41 | while (buf < buf_end) { |
| 42 | 42 | start_code= -1; |
| 43 | − buf= ff_find_start_code(buf, buf_end, &start_code); | |
| 43 | + buf= avpriv_mpv_find_start_code(buf, buf_end, &start_code); | |
| 44 | 44 | bytes_left = buf_end - buf; |
| 45 | 45 | switch(start_code) { |
| 46 | 46 | case PICTURE_START_CODE: |
| @@ -57,8 +57,8 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, · 10 unmodified lines | ||
| 57 | 57 | did_set_size=1; |
| 58 | 58 | } |
| 59 | 59 | frame_rate_index = buf[3] & 0xf; |
| 60 | − pc->frame_rate.den = avctx->time_base.den = ff_frame_rate_tab[frame_rate_index].num; | |
| 61 | − pc->frame_rate.num = avctx->time_base.num = ff_frame_rate_tab[frame_rate_index].den; | |
| 60 | + pc->frame_rate.den = avctx->time_base.den = avpriv_frame_rate_tab[frame_rate_index].num; | |
| 61 | + pc->frame_rate.num = avctx->time_base.num = avpriv_frame_rate_tab[frame_rate_index].den; | |
| 62 | 62 | avctx->bit_rate = ((buf[4]<<10) | (buf[5]<<2) | (buf[6]>>6))*400; |
| 63 | 63 | avctx->codec_id = CODEC_ID_MPEG1VIDEO; |
| 64 | 64 | avctx->sub_id = 1; |
| @@ -351,7 +351,7 @@ void msmpeg4_encode_picture_header(MpegEncContext * s, int picture_number) · 350 unmodified lines | ||
| 351 | 351 | { |
| 352 | 352 | find_best_tables(s); |
| 353 | 353 | |
| 354 | − align_put_bits(&s->pb); | |
| 354 | + avpriv_align_put_bits(&s->pb); | |
| 355 | 355 | put_bits(&s->pb, 2, s->pict_type - 1); |
| 356 | 356 | |
| 357 | 357 | put_bits(&s->pb, 5, s->qscale); |
| @@ -97,14 +97,14 @@ static inline void flush_put_bits(PutBitContext *s) · 96 unmodified lines | ||
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | #ifdef BITSTREAM_WRITER_LE |
| 100 | −#define align_put_bits align_put_bits_unsupported_here | |
| 100 | +#define avpriv_align_put_bits align_put_bits_unsupported_here | |
| 101 | 101 | #define ff_put_string ff_put_string_unsupported_here |
| 102 | −#define ff_copy_bits ff_copy_bits_unsupported_here | |
| 102 | +#define avpriv_copy_bits avpriv_copy_bits_unsupported_here | |
| 103 | 103 | #else |
| 104 | 104 | /** |
| 105 | 105 | * Pad the bitstream with zeros up to the next byte boundary. |
| 106 | 106 | */ |
| 107 | −void align_put_bits(PutBitContext *s); | |
| 107 | +void avpriv_align_put_bits(PutBitContext *s); | |
| 108 | 108 | |
| 109 | 109 | /** |
| 110 | 110 | * Put the string string in the bitstream. |
| @@ -118,7 +118,7 @@ void ff_put_string(PutBitContext *pb, const char *string, int terminate_string); · 7 unmodified lines | ||
| 118 | 118 | * |
| 119 | 119 | * @param length the number of bits of src to copy |
| 120 | 120 | */ |
| 121 | −void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length); | |
| 121 | +void avpriv_copy_bits(PutBitContext *pb, const uint8_t *src, int length); | |
| 122 | 122 | #endif |
| 123 | 123 | |
| 124 | 124 | /** |
| @@ -32,7 +32,7 @@ void rv10_encode_picture_header(MpegEncContext *s, int picture_number) · 31 unmodified lines | ||
| 32 | 32 | { |
| 33 | 33 | int full_frame= 0; |
| 34 | 34 | |
| 35 | − align_put_bits(&s->pb); | |
| 35 | + avpriv_align_put_bits(&s->pb); | |
| 36 | 36 | |
| 37 | 37 | put_bits(&s->pb, 1, 1); /* marker */ |
| 38 | 38 | |
| @@ -28,6 +28,7 @@ · 27 unmodified lines | ||
| 28 | 28 | |
| 29 | 29 | #include <limits.h> |
| 30 | 30 | #include "avcodec.h" |
| 31 | +#include "bytestream.h" | |
| 31 | 32 | #include "get_bits.h" |
| 32 | 33 | #include "golomb.h" |
| 33 | 34 | |
| @@ -69,6 +70,9 @@ · 35 unmodified lines | ||
| 69 | 70 | #define FN_ZERO 8 |
| 70 | 71 | #define FN_VERBATIM 9 |
| 71 | 72 | |
| 73 | +/** indicates if the FN_* command is audio or non-audio */ | |
| 74 | +static const uint8_t is_audio_command[10] = { 1, 1, 1, 1, 0, 0, 0, 1, 1, 0 }; | |
| 75 | + | |
| 72 | 76 | #define VERBATIM_CKSIZE_SIZE 5 |
| 73 | 77 | #define VERBATIM_BYTE_SIZE 8 |
| 74 | 78 | #define CANONICAL_HEADER_SIZE 44 |
| @@ -98,6 +102,8 @@ typedef struct ShortenContext { · 23 unmodified lines | ||
| 98 | 102 | int blocksize; |
| 99 | 103 | int bitindex; |
| 100 | 104 | int32_t lpcqoffset; |
| 105 | + int got_header; | |
| 106 | + int got_quit_command; | |
| 101 | 107 | } ShortenContext; |
| 102 | 108 | |
| 103 | 109 | static av_cold int shorten_decode_init(AVCodecContext * avctx) |
| @@ -113,6 +119,7 @@ static int allocate_buffers(ShortenContext *s) · 9 unmodified lines | ||
| 113 | 119 | { |
| 114 | 120 | int i, chan; |
| 115 | 121 | int *coeffs; |
| 122 | + void *tmp_ptr; | |
| 116 | 123 | |
| 117 | 124 | for (chan=0; chan<s->channels; chan++) { |
| 118 | 125 | if(FFMAX(1, s->nmean) >= UINT_MAX/sizeof(int32_t)){ |
| @@ -124,9 +131,15 @@ static int allocate_buffers(ShortenContext *s) · 5 unmodified lines | ||
| 124 | 131 | return -1; |
| 125 | 132 | } |
| 126 | 133 | |
| 127 | − s->offset[chan] = av_realloc(s->offset[chan], sizeof(int32_t)*FFMAX(1, s->nmean)); | |
| 134 | + tmp_ptr = av_realloc(s->offset[chan], sizeof(int32_t)*FFMAX(1, s->nmean)); | |
| 135 | + if (!tmp_ptr) | |
| 136 | + return AVERROR(ENOMEM); | |
| 137 | + s->offset[chan] = tmp_ptr; | |
| 128 | 138 | |
| 129 | − s->decoded[chan] = av_realloc(s->decoded[chan], sizeof(int32_t)*(s->blocksize + s->nwrap)); | |
| 139 | + tmp_ptr = av_realloc(s->decoded[chan], sizeof(int32_t)*(s->blocksize + s->nwrap)); | |
| 140 | + if (!tmp_ptr) | |
| 141 | + return AVERROR(ENOMEM); | |
| 142 | + s->decoded[chan] = tmp_ptr; | |
| 130 | 143 | for (i=0; i<s->nwrap; i++) |
| 131 | 144 | s->decoded[chan][i] = 0; |
| 132 | 145 | s->decoded[chan] += s->nwrap; |
| @@ -181,47 +194,37 @@ static void init_offset(ShortenContext *s) · 48 unmodified lines | ||
| 181 | 194 | s->offset[chan][i] = mean; |
| 182 | 195 | } |
| 183 | 196 | |
| 184 | −static inline int get_le32(GetBitContext *gb) | |
| 185 | −{ | |
| 186 | − return av_bswap32(get_bits_long(gb, 32)); | |
| 187 | −} | |
| 188 | − | |
| 189 | −static inline short get_le16(GetBitContext *gb) | |
| 190 | −{ | |
| 191 | − return av_bswap16(get_bits_long(gb, 16)); | |
| 192 | −} | |
| 193 | − | |
| 194 | −static int decode_wave_header(AVCodecContext *avctx, uint8_t *header, int header_size) | |
| 197 | +static int decode_wave_header(AVCodecContext *avctx, const uint8_t *header, | |
| 198 | + int header_size) | |
| 195 | 199 | { |
| 196 | − GetBitContext hb; | |
| 197 | 200 | int len; |
| 198 | 201 | short wave_format; |
| 199 | 202 | |
| 200 | − init_get_bits(&hb, header, header_size*8); | |
| 201 | − if (get_le32(&hb) != MKTAG('R','I','F','F')) { | |
| 203 | + | |
| 204 | + if (bytestream_get_le32(&header) != MKTAG('R','I','F','F')) { | |
| 202 | 205 | av_log(avctx, AV_LOG_ERROR, "missing RIFF tag\n"); |
| 203 | 206 | return -1; |
| 204 | 207 | } |
| 205 | 208 | |
| 206 | − skip_bits_long(&hb, 32); /* chunk_size */ | |
| 209 | + header += 4; /* chunk size */; | |
| 207 | 210 | |
| 208 | − if (get_le32(&hb) != MKTAG('W','A','V','E')) { | |
| 211 | + if (bytestream_get_le32(&header) != MKTAG('W','A','V','E')) { | |
| 209 | 212 | av_log(avctx, AV_LOG_ERROR, "missing WAVE tag\n"); |
| 210 | 213 | return -1; |
| 211 | 214 | } |
| 212 | 215 | |
| 213 | − while (get_le32(&hb) != MKTAG('f','m','t',' ')) { | |
| 214 | − len = get_le32(&hb); | |
| 215 | − skip_bits(&hb, 8*len); | |
| 216 | + while (bytestream_get_le32(&header) != MKTAG('f','m','t',' ')) { | |
| 217 | + len = bytestream_get_le32(&header); | |
| 218 | + header += len; | |
| 216 | 219 | } |
| 217 | − len = get_le32(&hb); | |
| 220 | + len = bytestream_get_le32(&header); | |
| 218 | 221 | |
| 219 | 222 | if (len < 16) { |
| 220 | 223 | av_log(avctx, AV_LOG_ERROR, "fmt chunk was too short\n"); |
| 221 | 224 | return -1; |
| 222 | 225 | } |
| 223 | 226 | |
| 224 | − wave_format = get_le16(&hb); | |
| 227 | + wave_format = bytestream_get_le16(&header); | |
| 225 | 228 | |
| 226 | 229 | switch (wave_format) { |
| 227 | 230 | case WAVE_FORMAT_PCM: |
| @@ -231,11 +234,11 @@ static int decode_wave_header(AVCodecContext *avctx, uint8_t *header, int header · 3 unmodified lines | ||
| 231 | 234 | return -1; |
| 232 | 235 | } |
| 233 | 236 | |
| 234 | − avctx->channels = get_le16(&hb); | |
| 235 | − avctx->sample_rate = get_le32(&hb); | |
| 236 | − avctx->bit_rate = get_le32(&hb) * 8; | |
| 237 | − avctx->block_align = get_le16(&hb); | |
| 238 | − avctx->bits_per_coded_sample = get_le16(&hb); | |
| 237 | + header += 2; // skip channels (already got from shorten header) | |
| 238 | + avctx->sample_rate = bytestream_get_le32(&header); | |
| 239 | + header += 4; // skip bit rate (represents original uncompressed bit rate) | |
| 240 | + header += 2; // skip block align (not needed) | |
| 241 | + avctx->bits_per_coded_sample = bytestream_get_le16(&header); | |
| 239 | 242 | |
| 240 | 243 | if (avctx->bits_per_coded_sample != 16) { |
| 241 | 244 | av_log(avctx, AV_LOG_ERROR, "unsupported number of bits per sample\n"); |
| @@ -253,26 +256,142 @@ static int16_t * interleave_buffer(int16_t *samples, int nchan, int blocksize, i · 11 unmodified lines | ||
| 253 | 256 | int i, chan; |
| 254 | 257 | for (i=0; i<blocksize; i++) |
| 255 | 258 | for (chan=0; chan < nchan; chan++) |
| 256 | − *samples++ = FFMIN(buffer[chan][i], 32768); | |
| 259 | + *samples++ = av_clip_int16(buffer[chan][i]); | |
| 257 | 260 | return samples; |
| 258 | 261 | } |
| 259 | 262 | |
| 260 | −static void decode_subframe_lpc(ShortenContext *s, int channel, int residual_size, int pred_order) | |
| 263 | +static const int fixed_coeffs[3][3] = { | |
| 264 | + { 1, 0, 0 }, | |
| 265 | + { 2, -1, 0 }, | |
| 266 | + { 3, -3, 1 } | |
| 267 | +}; | |
| 268 | + | |
| 269 | +static int decode_subframe_lpc(ShortenContext *s, int command, int channel, | |
| 270 | + int residual_size, int32_t coffset) | |
| 261 | 271 | { |
| 262 | − int sum, i, j; | |
| 263 | − int *coeffs = s->coeffs; | |
| 272 | + int pred_order, sum, qshift, init_sum, i, j; | |
| 273 | + const int *coeffs; | |
| 274 | + | |
| 275 | + if (command == FN_QLPC) { | |
| 276 | + /* read/validate prediction order */ | |
| 277 | + pred_order = get_ur_golomb_shorten(&s->gb, LPCQSIZE); | |
| 278 | + if (pred_order > s->nwrap) { | |
| 279 | + av_log(s->avctx, AV_LOG_ERROR, "invalid pred_order %d\n", pred_order); | |
| 280 | + return AVERROR(EINVAL); | |
| 281 | + } | |
| 282 | + /* read LPC coefficients */ | |
| 283 | + for (i=0; i<pred_order; i++) | |
| 284 | + s->coeffs[i] = get_sr_golomb_shorten(&s->gb, LPCQUANT); | |
| 285 | + coeffs = s->coeffs; | |
| 286 | + | |
| 287 | + qshift = LPCQUANT; | |
| 288 | + } else { | |
| 289 | + /* fixed LPC coeffs */ | |
| 290 | + pred_order = command; | |
| 291 | + coeffs = fixed_coeffs[pred_order-1]; | |
| 292 | + qshift = 0; | |
| 293 | + } | |
| 264 | 294 | |
| 265 | − for (i=0; i<pred_order; i++) | |
| 266 | − coeffs[i] = get_sr_golomb_shorten(&s->gb, LPCQUANT); | |
| 295 | + /* subtract offset from previous samples to use in prediction */ | |
| 296 | + if (command == FN_QLPC && coffset) | |
| 297 | + for (i = -pred_order; i < 0; i++) | |
| 298 | + s->decoded[channel][i] -= coffset; | |
| 267 | 299 | |
| 300 | + /* decode residual and do LPC prediction */ | |
| 301 | + init_sum = pred_order ? (command == FN_QLPC ? s->lpcqoffset : 0) : coffset; | |
| 268 | 302 | for (i=0; i < s->blocksize; i++) { |
| 269 | − sum = s->lpcqoffset; | |
| 303 | + sum = init_sum; | |
| 270 | 304 | for (j=0; j<pred_order; j++) |
| 271 | 305 | sum += coeffs[j] * s->decoded[channel][i-j-1]; |
| 272 | − s->decoded[channel][i] = get_sr_golomb_shorten(&s->gb, residual_size) + (sum >> LPCQUANT); | |
| 306 | + s->decoded[channel][i] = get_sr_golomb_shorten(&s->gb, residual_size) + (sum >> qshift); | |
| 273 | 307 | } |
| 308 | + | |
| 309 | + /* add offset to current samples */ | |
| 310 | + if (command == FN_QLPC && coffset) | |
| 311 | + for (i = 0; i < s->blocksize; i++) | |
| 312 | + s->decoded[channel][i] += coffset; | |
| 313 | + | |
| 314 | + return 0; | |
| 274 | 315 | } |
| 275 | 316 | |
| 317 | +static int read_header(ShortenContext *s) | |
| 318 | +{ | |
| 319 | + int i, ret; | |
| 320 | + int maxnlpc = 0; | |
| 321 | + /* shorten signature */ | |
| 322 | + if (get_bits_long(&s->gb, 32) != AV_RB32("ajkg")) { | |
| 323 | + av_log(s->avctx, AV_LOG_ERROR, "missing shorten magic 'ajkg'\n"); | |
| 324 | + return -1; | |
| 325 | + } | |
| 326 | + | |
| 327 | + s->lpcqoffset = 0; | |
| 328 | + s->blocksize = DEFAULT_BLOCK_SIZE; | |
| 329 | + s->channels = 1; | |
| 330 | + s->nmean = -1; | |
| 331 | + s->version = get_bits(&s->gb, 8); | |
| 332 | + s->internal_ftype = get_uint(s, TYPESIZE); | |
| 333 | + | |
| 334 | + s->channels = get_uint(s, CHANSIZE); | |
| 335 | + if (s->channels > MAX_CHANNELS) { | |
| 336 | + av_log(s->avctx, AV_LOG_ERROR, "too many channels: %d\n", s->channels); | |
| 337 | + return -1; | |
| 338 | + } | |
| 339 | + s->avctx->channels = s->channels; | |
| 340 | + | |
| 341 | + /* get blocksize if version > 0 */ | |
| 342 | + if (s->version > 0) { | |
| 343 | + int skip_bytes, blocksize; | |
| 344 | + | |
| 345 | + blocksize = get_uint(s, av_log2(DEFAULT_BLOCK_SIZE)); | |
| 346 | + if (!blocksize || blocksize > MAX_BLOCKSIZE) { | |
| 347 | + av_log(s->avctx, AV_LOG_ERROR, "invalid or unsupported block size: %d\n", | |
| 348 | + blocksize); | |
| 349 | + return AVERROR(EINVAL); | |
| 350 | + } | |
| 351 | + s->blocksize = blocksize; | |
| 352 | + | |
| 353 | + maxnlpc = get_uint(s, LPCQSIZE); | |
| 354 | + s->nmean = get_uint(s, 0); | |
| 355 | + | |
| 356 | + skip_bytes = get_uint(s, NSKIPSIZE); | |
| 357 | + for (i=0; i<skip_bytes; i++) { | |
| 358 | + skip_bits(&s->gb, 8); | |
| 359 | + } | |
| 360 | + } | |
| 361 | + s->nwrap = FFMAX(NWRAP, maxnlpc); | |
| 362 | + | |
| 363 | + if ((ret = allocate_buffers(s)) < 0) | |
| 364 | + return ret; | |
| 365 | + | |
| 366 | + init_offset(s); | |
| 367 | + | |
| 368 | + if (s->version > 1) | |
| 369 | + s->lpcqoffset = V2LPCQOFFSET; | |
| 370 | + | |
| 371 | + if (get_ur_golomb_shorten(&s->gb, FNSIZE) != FN_VERBATIM) { | |
| 372 | + av_log(s->avctx, AV_LOG_ERROR, "missing verbatim section at beginning of stream\n"); | |
| 373 | + return -1; | |
| 374 | + } | |
| 375 | + | |
| 376 | + s->header_size = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE); | |
| 377 | + if (s->header_size >= OUT_BUFFER_SIZE || s->header_size < CANONICAL_HEADER_SIZE) { | |
| 378 | + av_log(s->avctx, AV_LOG_ERROR, "header is wrong size: %d\n", s->header_size); | |
| 379 | + return -1; | |
| 380 | + } | |
| 381 | + | |
| 382 | + for (i=0; i<s->header_size; i++) | |
| 383 | + s->header[i] = (char)get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE); | |
| 384 | + | |
| 385 | + if (decode_wave_header(s->avctx, s->header, s->header_size) < 0) | |
| 386 | + return -1; | |
| 387 | + | |
| 388 | + s->cur_chan = 0; | |
| 389 | + s->bitshift = 0; | |
| 390 | + | |
| 391 | + s->got_header = 1; | |
| 392 | + | |
| 393 | + return 0; | |
| 394 | +} | |
| 276 | 395 | |
| 277 | 396 | static int shorten_decode_frame(AVCodecContext *avctx, |
| 278 | 397 | void *data, int *data_size, |
| @@ -283,226 +402,189 @@ static int shorten_decode_frame(AVCodecContext *avctx, · 4 unmodified lines | ||
| 283 | 402 | ShortenContext *s = avctx->priv_data; |
| 284 | 403 | int i, input_buf_size = 0; |
| 285 | 404 | int16_t *samples = data; |
| 405 | + int ret; | |
| 406 | + | |
| 407 | + /* allocate internal bitstream buffer */ | |
| 286 | 408 | if(s->max_framesize == 0){ |
| 409 | + void *tmp_ptr; | |
| 287 | 410 | s->max_framesize= 1024; // should hopefully be enough for the first header |
| 288 | − s->bitstream= av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, s->max_framesize); | |
| 411 | + tmp_ptr = av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, | |
| 412 | + s->max_framesize); | |
| 413 | + if (!tmp_ptr) { | |
| 414 | + av_log(avctx, AV_LOG_ERROR, "error allocating bitstream buffer\n"); | |
| 415 | + return AVERROR(ENOMEM); | |
| 416 | + } | |
| 417 | + s->bitstream = tmp_ptr; | |
| 289 | 418 | } |
| 290 | 419 | |
| 420 | + /* append current packet data to bitstream buffer */ | |
| 291 | 421 | if(1 && s->max_framesize){//FIXME truncated |
| 292 | 422 | buf_size= FFMIN(buf_size, s->max_framesize - s->bitstream_size); |
| 293 | 423 | input_buf_size= buf_size; |
| 294 | 424 | |
| 295 | 425 | if(s->bitstream_index + s->bitstream_size + buf_size > s->allocated_bitstream_size){ |
| 296 | − // printf("memmove\n"); | |
| 297 | 426 | memmove(s->bitstream, &s->bitstream[s->bitstream_index], s->bitstream_size); |
| 298 | 427 | s->bitstream_index=0; |
| 299 | 428 | } |
| 300 | − memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size], buf, buf_size); | |
| 429 | + if (buf) | |
| 430 | + memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size], buf, buf_size); | |
| 301 | 431 | buf= &s->bitstream[s->bitstream_index]; |
| 302 | 432 | buf_size += s->bitstream_size; |
| 303 | 433 | s->bitstream_size= buf_size; |
| 304 | 434 | |
| 305 | − if(buf_size < s->max_framesize){ | |
| 435 | + /* do not decode until buffer has at least max_framesize bytes or | |
| 436 | + the end of the file has been reached */ | |
| 437 | + if (buf_size < s->max_framesize && avpkt->data) { | |
| 306 | 438 | *data_size = 0; |
| 307 | 439 | return input_buf_size; |
| 308 | 440 | } |
| 309 | 441 | } |
| 442 | + /* init and position bitstream reader */ | |
| 310 | 443 | init_get_bits(&s->gb, buf, buf_size*8); |
| 311 | 444 | skip_bits(&s->gb, s->bitindex); |
| 312 | − if (!s->blocksize) | |
| 313 | − { | |
| 314 | − int maxnlpc = 0; | |
| 315 | − /* shorten signature */ | |
| 316 | − if (get_bits_long(&s->gb, 32) != AV_RB32("ajkg")) { | |
| 317 | − av_log(s->avctx, AV_LOG_ERROR, "missing shorten magic 'ajkg'\n"); | |
| 318 | − return -1; | |
| 319 | − } | |
| 320 | 445 | |
| 321 | − s->lpcqoffset = 0; | |
| 322 | − s->blocksize = DEFAULT_BLOCK_SIZE; | |
| 323 | − s->channels = 1; | |
| 324 | − s->nmean = -1; | |
| 325 | − s->version = get_bits(&s->gb, 8); | |
| 326 | − s->internal_ftype = get_uint(s, TYPESIZE); | |
| 446 | + /* process header or next subblock */ | |
| 447 | + if (!s->got_header) { | |
| 448 | + if ((ret = read_header(s)) < 0) | |
| 449 | + return ret; | |
| 450 | + *data_size = 0; | |
| 451 | + goto finish_frame; | |
| 452 | + } | |
| 327 | 453 | |
| 328 | − s->channels = get_uint(s, CHANSIZE); | |
| 329 | − if (s->channels > MAX_CHANNELS) { | |
| 330 | − av_log(s->avctx, AV_LOG_ERROR, "too many channels: %d\n", s->channels); | |
| 331 | − return -1; | |
| 332 | − } | |
| 454 | + /* if quit command was read previously, don't decode anything */ | |
| 455 | + if (s->got_quit_command) { | |
| 456 | + *data_size = 0; | |
| 457 | + return avpkt->size; | |
| 458 | + } | |
| 333 | 459 | |
| 334 | − /* get blocksize if version > 0 */ | |
| 335 | − if (s->version > 0) { | |
| 336 | − int skip_bytes; | |
| 337 | − s->blocksize = get_uint(s, av_log2(DEFAULT_BLOCK_SIZE)); | |
| 338 | − maxnlpc = get_uint(s, LPCQSIZE); | |
| 339 | − s->nmean = get_uint(s, 0); | |
| 460 | + s->cur_chan = 0; | |
| 461 | + while (s->cur_chan < s->channels) { | |
| 462 | + int cmd; | |
| 463 | + int len; | |
| 340 | 464 | |
| 341 | − skip_bytes = get_uint(s, NSKIPSIZE); | |
| 342 | − for (i=0; i<skip_bytes; i++) { | |
| 343 | − skip_bits(&s->gb, 8); | |
| 344 | − } | |
| 465 | + if (get_bits_left(&s->gb) < 3+FNSIZE) { | |
| 466 | + *data_size = 0; | |
| 467 | + break; | |
| 345 | 468 | } |
| 346 | − s->nwrap = FFMAX(NWRAP, maxnlpc); | |
| 347 | − | |
| 348 | − if (allocate_buffers(s)) | |
| 349 | − return -1; | |
| 350 | 469 | |
| 351 | − init_offset(s); | |
| 352 | − | |
| 353 | − if (s->version > 1) | |
| 354 | − s->lpcqoffset = V2LPCQOFFSET; | |
| 470 | + cmd = get_ur_golomb_shorten(&s->gb, FNSIZE); | |
| 355 | 471 | |
| 356 | − if (get_ur_golomb_shorten(&s->gb, FNSIZE) != FN_VERBATIM) { | |
| 357 | − av_log(s->avctx, AV_LOG_ERROR, "missing verbatim section at beginning of stream\n"); | |
| 358 | − return -1; | |
| 472 | + if (cmd > FN_VERBATIM) { | |
| 473 | + av_log(avctx, AV_LOG_ERROR, "unknown shorten function %d\n", cmd); | |
| 474 | + *data_size = 0; | |
| 475 | + break; | |
| 359 | 476 | } |
| 360 | 477 | |
| 361 | − s->header_size = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE); | |
| 362 | − if (s->header_size >= OUT_BUFFER_SIZE || s->header_size < CANONICAL_HEADER_SIZE) { | |
| 363 | − av_log(s->avctx, AV_LOG_ERROR, "header is wrong size: %d\n", s->header_size); | |
| 364 | − return -1; | |
| 365 | − } | |
| 478 | + if (!is_audio_command[cmd]) { | |
| 479 | + /* process non-audio command */ | |
| 480 | + switch (cmd) { | |
| 481 | + case FN_VERBATIM: | |
| 482 | + len = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE); | |
| 483 | + while (len--) { | |
| 484 | + get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE); | |
| 485 | + } | |
| 486 | + break; | |
| 487 | + case FN_BITSHIFT: | |
| 488 | + s->bitshift = get_ur_golomb_shorten(&s->gb, BITSHIFTSIZE); | |
| 489 | + break; | |
| 490 | + case FN_BLOCKSIZE: { | |
| 491 | + int blocksize = get_uint(s, av_log2(s->blocksize)); | |
| 492 | + if (blocksize > s->blocksize) { | |
| 493 | + av_log(avctx, AV_LOG_ERROR, "Increasing block size is not supported\n"); | |
| 494 | + return AVERROR_PATCHWELCOME; | |
| 495 | + } | |
| 496 | + if (!blocksize || blocksize > MAX_BLOCKSIZE) { | |
| 497 | + av_log(avctx, AV_LOG_ERROR, "invalid or unsupported " | |
| 498 | + "block size: %d\n", blocksize); | |
| 499 | + return AVERROR(EINVAL); | |
| 500 | + } | |
| 501 | + s->blocksize = blocksize; | |
| 502 | + break; | |
| 503 | + } | |
| 504 | + case FN_QUIT: | |
| 505 | + s->got_quit_command = 1; | |
| 506 | + break; | |
| 507 | + } | |
| 508 | + if (cmd == FN_BLOCKSIZE || cmd == FN_QUIT) { | |
| 509 | + *data_size = 0; | |
| 510 | + break; | |
| 511 | + } | |
| 512 | + } else { | |
| 513 | + /* process audio command */ | |
| 514 | + int residual_size = 0; | |
| 515 | + int channel = s->cur_chan; | |
| 516 | + int32_t coffset; | |
| 517 | + | |
| 518 | + /* get Rice code for residual decoding */ | |
| 519 | + if (cmd != FN_ZERO) { | |
| 520 | + residual_size = get_ur_golomb_shorten(&s->gb, ENERGYSIZE); | |
| 521 | + /* this is a hack as version 0 differed in defintion of get_sr_golomb_shorten */ | |
| 522 | + if (s->version == 0) | |
| 523 | + residual_size--; | |
| 524 | + } | |
| 366 | 525 | |
| 367 | − for (i=0; i<s->header_size; i++) | |
| 368 | − s->header[i] = (char)get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE); | |
| 526 | + /* calculate sample offset using means from previous blocks */ | |
| 527 | + if (s->nmean == 0) | |
| 528 | + coffset = s->offset[channel][0]; | |
| 529 | + else { | |
| 530 | + int32_t sum = (s->version < 2) ? 0 : s->nmean / 2; | |
| 531 | + for (i=0; i<s->nmean; i++) | |
| 532 | + sum += s->offset[channel][i]; | |
| 533 | + coffset = sum / s->nmean; | |
| 534 | + if (s->version >= 2) | |
| 535 | + coffset >>= FFMIN(1, s->bitshift); | |
| 536 | + } | |
| 369 | 537 | |
| 370 | − if (decode_wave_header(avctx, s->header, s->header_size) < 0) | |
| 371 | − return -1; | |
| 538 | + /* decode samples for this channel */ | |
| 539 | + if (cmd == FN_ZERO) { | |
| 540 | + for (i=0; i<s->blocksize; i++) | |
| 541 | + s->decoded[channel][i] = 0; | |
| 542 | + } else { | |
| 543 | + if ((ret = decode_subframe_lpc(s, cmd, channel, residual_size, coffset)) < 0) | |
| 544 | + return ret; | |
| 545 | + } | |
| 372 | 546 | |
| 373 | − s->cur_chan = 0; | |
| 374 | − s->bitshift = 0; | |
| 375 | − } | |
| 376 | − else | |
| 377 | − { | |
| 378 | − int cmd; | |
| 379 | − int len; | |
| 380 | − cmd = get_ur_golomb_shorten(&s->gb, FNSIZE); | |
| 381 | − switch (cmd) { | |
| 382 | − case FN_ZERO: | |
| 383 | − case FN_DIFF0: | |
| 384 | − case FN_DIFF1: | |
| 385 | − case FN_DIFF2: | |
| 386 | − case FN_DIFF3: | |
| 387 | − case FN_QLPC: | |
| 388 | − { | |
| 389 | − int residual_size = 0; | |
| 390 | − int channel = s->cur_chan; | |
| 391 | − int32_t coffset; | |
| 392 | − if (cmd != FN_ZERO) { | |
| 393 | − residual_size = get_ur_golomb_shorten(&s->gb, ENERGYSIZE); | |
| 394 | − /* this is a hack as version 0 differed in defintion of get_sr_golomb_shorten */ | |
| 395 | − if (s->version == 0) | |
| 396 | − residual_size--; | |
| 397 | − } | |
| 547 | + /* update means with info from the current block */ | |
| 548 | + if (s->nmean > 0) { | |
| 549 | + int32_t sum = (s->version < 2) ? 0 : s->blocksize / 2; | |
| 550 | + for (i=0; i<s->blocksize; i++) | |
| 551 | + sum += s->decoded[channel][i]; | |
| 398 | 552 | |
| 399 | − if (s->nmean == 0) | |
| 400 | − coffset = s->offset[channel][0]; | |
| 401 | − else { | |
| 402 | − int32_t sum = (s->version < 2) ? 0 : s->nmean / 2; | |
| 403 | − for (i=0; i<s->nmean; i++) | |
| 404 | − sum += s->offset[channel][i]; | |
| 405 | − coffset = sum / s->nmean; | |
| 406 | − if (s->version >= 2) | |
| 407 | − coffset >>= FFMIN(1, s->bitshift); | |
| 408 | − } | |
| 409 | − switch (cmd) { | |
| 410 | − case FN_ZERO: | |
| 411 | − for (i=0; i<s->blocksize; i++) | |
| 412 | − s->decoded[channel][i] = 0; | |
| 413 | − break; | |
| 414 | − case FN_DIFF0: | |
| 415 | − for (i=0; i<s->blocksize; i++) | |
| 416 | − s->decoded[channel][i] = get_sr_golomb_shorten(&s->gb, residual_size) + coffset; | |
| 417 | − break; | |
| 418 | − case FN_DIFF1: | |
| 419 | − for (i=0; i<s->blocksize; i++) | |
| 420 | − s->decoded[channel][i] = get_sr_golomb_shorten(&s->gb, residual_size) + s->decoded[channel][i - 1]; | |
| 421 | − break; | |
| 422 | − case FN_DIFF2: | |
| 423 | − for (i=0; i<s->blocksize; i++) | |
| 424 | − s->decoded[channel][i] = get_sr_golomb_shorten(&s->gb, residual_size) + 2*s->decoded[channel][i-1] | |
| 425 | − - s->decoded[channel][i-2]; | |
| 426 | − break; | |
| 427 | − case FN_DIFF3: | |
| 428 | − for (i=0; i<s->blocksize; i++) | |
| 429 | − s->decoded[channel][i] = get_sr_golomb_shorten(&s->gb, residual_size) + 3*s->decoded[channel][i-1] | |
| 430 | − - 3*s->decoded[channel][i-2] | |
| 431 | − + s->decoded[channel][i-3]; | |
| 432 | − break; | |
| 433 | − case FN_QLPC: | |
| 434 | − { | |
| 435 | − int pred_order = get_ur_golomb_shorten(&s->gb, LPCQSIZE); | |
| 436 | − if (pred_order > s->nwrap) { | |
| 437 | − av_log(avctx, AV_LOG_ERROR, | |
| 438 | − "invalid pred_order %d\n", | |
| 439 | − pred_order); | |
| 440 | − return -1; | |
| 441 | − } | |
| 442 | − for (i=0; i<pred_order; i++) | |
| 443 | − s->decoded[channel][i - pred_order] -= coffset; | |
| 444 | − decode_subframe_lpc(s, channel, residual_size, pred_order); | |
| 445 | − if (coffset != 0) | |
| 446 | − for (i=0; i < s->blocksize; i++) | |
| 447 | − s->decoded[channel][i] += coffset; | |
| 448 | − } | |
| 449 | − } | |
| 450 | − if (s->nmean > 0) { | |
| 451 | − int32_t sum = (s->version < 2) ? 0 : s->blocksize / 2; | |
| 452 | − for (i=0; i<s->blocksize; i++) | |
| 453 | − sum += s->decoded[channel][i]; | |
| 454 | − | |
| 455 | − for (i=1; i<s->nmean; i++) | |
| 456 | − s->offset[channel][i-1] = s->offset[channel][i]; | |
| 457 | − | |
| 458 | − if (s->version < 2) | |
| 459 | − s->offset[channel][s->nmean - 1] = sum / s->blocksize; | |
| 460 | − else | |
| 461 | − s->offset[channel][s->nmean - 1] = (sum / s->blocksize) << s->bitshift; | |
| 462 | − } | |
| 463 | − for (i=-s->nwrap; i<0; i++) | |
| 464 | − s->decoded[channel][i] = s->decoded[channel][i + s->blocksize]; | |
| 553 | + for (i=1; i<s->nmean; i++) | |
| 554 | + s->offset[channel][i-1] = s->offset[channel][i]; | |
| 465 | 555 | |
| 466 | − fix_bitshift(s, s->decoded[channel]); | |
| 556 | + if (s->version < 2) | |
| 557 | + s->offset[channel][s->nmean - 1] = sum / s->blocksize; | |
| 558 | + else | |
| 559 | + s->offset[channel][s->nmean - 1] = (sum / s->blocksize) << s->bitshift; | |
| 560 | + } | |
| 467 | 561 | |
| 468 | − s->cur_chan++; | |
| 469 | − if (s->cur_chan == s->channels) { | |
| 470 | − samples = interleave_buffer(samples, s->channels, s->blocksize, s->decoded); | |
| 471 | − s->cur_chan = 0; | |
| 472 | − goto frame_done; | |
| 473 | − } | |
| 474 | − } | |
| 475 | − break; | |
| 476 | − case FN_VERBATIM: | |
| 477 | − len = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE); | |
| 478 | − while (len--) { | |
| 479 | − get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE); | |
| 480 | − } | |
| 481 | − break; | |
| 482 | − case FN_BITSHIFT: | |
| 483 | − s->bitshift = get_ur_golomb_shorten(&s->gb, BITSHIFTSIZE); | |
| 484 | − break; | |
| 485 | − case FN_BLOCKSIZE: { | |
| 486 | − int blocksize = get_uint(s, av_log2(s->blocksize)); | |
| 487 | − if (blocksize > s->blocksize) { | |
| 488 | − av_log(avctx, AV_LOG_ERROR, "Increasing block size is not supported\n"); | |
| 489 | − return AVERROR_PATCHWELCOME; | |
| 562 | + /* copy wrap samples for use with next block */ | |
| 563 | + for (i=-s->nwrap; i<0; i++) | |
| 564 | + s->decoded[channel][i] = s->decoded[channel][i + s->blocksize]; | |
| 565 | + | |
| 566 | + /* shift samples to add in unused zero bits which were removed | |
| 567 | + during encoding */ | |
| 568 | + fix_bitshift(s, s->decoded[channel]); | |
| 569 | + | |
| 570 | + /* if this is the last channel in the block, output the samples */ | |
| 571 | + s->cur_chan++; | |
| 572 | + if (s->cur_chan == s->channels) { | |
| 573 | + int out_size = s->blocksize * s->channels * | |
| 574 | + av_get_bytes_per_sample(avctx->sample_fmt); | |
| 575 | + if (*data_size < out_size) { | |
| 576 | + av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); | |
| 577 | + return AVERROR(EINVAL); | |
| 490 | 578 | } |
| 491 | − s->blocksize = blocksize; | |
| 492 | − break; | |
| 579 | + samples = interleave_buffer(samples, s->channels, s->blocksize, s->decoded); | |
| 580 | + *data_size = out_size; | |
| 493 | 581 | } |
| 494 | − case FN_QUIT: | |
| 495 | − *data_size = 0; | |
| 496 | − return buf_size; | |
| 497 | − default: | |
| 498 | − av_log(avctx, AV_LOG_ERROR, "unknown shorten function %d\n", cmd); | |
| 499 | − return -1; | |
| 500 | 582 | } |
| 501 | 583 | } |
| 502 | −frame_done: | |
| 503 | − *data_size = (int8_t *)samples - (int8_t *)data; | |
| 584 | + if (s->cur_chan < s->channels) | |
| 585 | + *data_size = 0; | |
| 504 | 586 | |
| 505 | − // s->last_blocksize = s->blocksize; | |
| 587 | +finish_frame: | |
| 506 | 588 | s->bitindex = get_bits_count(&s->gb) - 8*((get_bits_count(&s->gb))/8); |
| 507 | 589 | i= (get_bits_count(&s->gb))/8; |
| 508 | 590 | if (i > buf_size) { |
| @@ -542,5 +624,6 @@ AVCodec ff_shorten_decoder = { · 33 unmodified lines | ||
| 542 | 624 | .init = shorten_decode_init, |
| 543 | 625 | .close = shorten_decode_close, |
| 544 | 626 | .decode = shorten_decode_frame, |
| 627 | + .capabilities = CODEC_CAP_DELAY, | |
| 545 | 628 | .long_name= NULL_IF_CONFIG_SMALL("Shorten"), |
| 546 | 629 | }; |
| @@ -461,7 +461,7 @@ static int svq1_encode_plane(SVQ1Context *s, int plane, unsigned char *src_plane · 460 unmodified lines | ||
| 461 | 461 | s->rd_total += score[best]; |
| 462 | 462 | |
| 463 | 463 | for(i=5; i>=0; i--){ |
| 464 | − ff_copy_bits(&s->pb, reorder_buffer[best][i], count[best][i]); | |
| 464 | + avpriv_copy_bits(&s->pb, reorder_buffer[best][i], count[best][i]); | |
| 465 | 465 | } |
| 466 | 466 | if(best==0){ |
| 467 | 467 | s->dsp.put_pixels_tab[0][0](decoded, temp, stride, 16); |
| @@ -540,7 +540,7 @@ static int svq1_encode_frame(AVCodecContext *avctx, unsigned char *buf, · 72 unmodified lines | ||
| 540 | 540 | return -1; |
| 541 | 541 | } |
| 542 | 542 | |
| 543 | −// align_put_bits(&s->pb); | |
| 543 | +// avpriv_align_put_bits(&s->pb); | |
| 544 | 544 | while(put_bits_count(&s->pb) & 31) |
| 545 | 545 | put_bits(&s->pb, 1, 0); |
| 546 | 546 | |
| @@ -1363,7 +1363,7 @@ int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)) · 1362 unmodified lines | ||
| 1363 | 1363 | return 0; |
| 1364 | 1364 | } |
| 1365 | 1365 | |
| 1366 | −unsigned int ff_toupper4(unsigned int x) | |
| 1366 | +unsigned int avpriv_toupper4(unsigned int x) | |
| 1367 | 1367 | { |
| 1368 | 1368 | return toupper( x &0xFF) |
| 1369 | 1369 | + (toupper((x>>8 )&0xFF)<<8 ) |
| @@ -132,7 +132,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, · 131 unmodified lines | ||
| 132 | 132 | |
| 133 | 133 | emms_c(); |
| 134 | 134 | |
| 135 | − align_put_bits(&a->pb); | |
| 135 | + avpriv_align_put_bits(&a->pb); | |
| 136 | 136 | while(get_bit_count(&a->pb)&31) |
| 137 | 137 | put_bits(&a->pb, 8, 0); |
| 138 | 138 | |
| @@ -21,7 +21,7 @@ · 20 unmodified lines | ||
| 21 | 21 | #define AVCODEC_VERSION_H |
| 22 | 22 | |
| 23 | 23 | #define LIBAVCODEC_VERSION_MAJOR 53 |
| 24 | −#define LIBAVCODEC_VERSION_MINOR 22 | |
| 24 | +#define LIBAVCODEC_VERSION_MINOR 23 | |
| 25 | 25 | #define LIBAVCODEC_VERSION_MICRO 0 |
| 26 | 26 | |
| 27 | 27 | #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |
| @@ -98,5 +98,8 @@ · 70 unmodified lines | ||
| 98 | 98 | #ifndef FF_API_MJPEG_GLOBAL_OPTS |
| 99 | 99 | #define FF_API_MJPEG_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54) |
| 100 | 100 | #endif |
| 101 | +#ifndef FF_API_GET_ALPHA_INFO | |
| 102 | +#define FF_API_GET_ALPHA_INFO (LIBAVCODEC_VERSION_MAJOR < 54) | |
| 103 | +#endif | |
| 101 | 104 | |
| 102 | 105 | #endif /* AVCODEC_VERSION_H */ |
| @@ -991,7 +991,7 @@ static av_cold int vorbis_decode_init(AVCodecContext *avccontext) · 990 unmodified lines | ||
| 991 | 991 | return -1; |
| 992 | 992 | } |
| 993 | 993 | |
| 994 | − if (ff_split_xiph_headers(headers, headers_len, 30, header_start, header_len) < 0) { | |
| 994 | + if (avpriv_split_xiph_headers(headers, headers_len, 30, header_start, header_len) < 0) { | |
| 995 | 995 | av_log(avccontext, AV_LOG_ERROR, "Extradata corrupt.\n"); |
| 996 | 996 | return -1; |
| 997 | 997 | } |
| @@ -2276,7 +2276,7 @@ static av_cold int theora_decode_init(AVCodecContext *avctx) · 2275 unmodified lines | ||
| 2276 | 2276 | return -1; |
| 2277 | 2277 | } |
| 2278 | 2278 | |
| 2279 | − if (ff_split_xiph_headers(avctx->extradata, avctx->extradata_size, | |
| 2279 | + if (avpriv_split_xiph_headers(avctx->extradata, avctx->extradata_size, | |
| 2280 | 2280 | 42, header_start, header_len) < 0) { |
| 2281 | 2281 | av_log(avctx, AV_LOG_ERROR, "Corrupt extradata\n"); |
| 2282 | 2282 | return -1; |
| @@ -311,7 +311,7 @@ static int encode_block(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE], · 310 unmodified lines | ||
| 311 | 311 | put_bits(&s->pb, s->coef_vlcs[tindex]->huffbits[1], s->coef_vlcs[tindex]->huffcodes[1]); |
| 312 | 312 | } |
| 313 | 313 | if (s->version == 1 && s->nb_channels >= 2) { |
| 314 | − align_put_bits(&s->pb); | |
| 314 | + avpriv_align_put_bits(&s->pb); | |
| 315 | 315 | } |
| 316 | 316 | } |
| 317 | 317 | return 0; |
| @@ -327,7 +327,7 @@ static int encode_frame(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE], · 9 unmodified lines | ||
| 327 | 327 | return INT_MAX; |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | − align_put_bits(&s->pb); | |
| 330 | + avpriv_align_put_bits(&s->pb); | |
| 331 | 331 | |
| 332 | 332 | return put_bits_count(&s->pb)/8 - s->block_align; |
| 333 | 333 | } |
| @@ -1446,14 +1446,14 @@ static void save_bits(WMAProDecodeCtx *s, GetBitContext* gb, int len, · 1445 unmodified lines | ||
| 1446 | 1446 | |
| 1447 | 1447 | s->num_saved_bits += len; |
| 1448 | 1448 | if (!append) { |
| 1449 | − ff_copy_bits(&s->pb, gb->buffer + (get_bits_count(gb) >> 3), | |
| 1449 | + avpriv_copy_bits(&s->pb, gb->buffer + (get_bits_count(gb) >> 3), | |
| 1450 | 1450 | s->num_saved_bits); |
| 1451 | 1451 | } else { |
| 1452 | 1452 | int align = 8 - (get_bits_count(gb) & 7); |
| 1453 | 1453 | align = FFMIN(align, len); |
| 1454 | 1454 | put_bits(&s->pb, align, get_bits(gb, align)); |
| 1455 | 1455 | len -= align; |
| 1456 | − ff_copy_bits(&s->pb, gb->buffer + (get_bits_count(gb) >> 3), len); | |
| 1456 | + avpriv_copy_bits(&s->pb, gb->buffer + (get_bits_count(gb) >> 3), len); | |
| 1457 | 1457 | } |
| 1458 | 1458 | skip_bits_long(gb, len); |
| 1459 | 1459 | |
| @@ -1872,7 +1872,7 @@ static int parse_packet_header(WMAVoiceContext *s) · 1871 unmodified lines | ||
| 1872 | 1872 | * @param size size of the source data, in bytes |
| 1873 | 1873 | * @param gb bit I/O context specifying the current position in the source. |
| 1874 | 1874 | * data. This function might use this to align the bit position to |
| 1875 | − * a whole-byte boundary before calling #ff_copy_bits() on aligned | |
| 1875 | + * a whole-byte boundary before calling #avpriv_copy_bits() on aligned | |
| 1876 | 1876 | * source data |
| 1877 | 1877 | * @param nbits the amount of bits to copy from source to target |
| 1878 | 1878 | * |
| @@ -1893,7 +1893,7 @@ static void copy_bits(PutBitContext *pb, · 14 unmodified lines | ||
| 1893 | 1893 | rmn_bits &= 7; rmn_bytes >>= 3; |
| 1894 | 1894 | if ((rmn_bits = FFMIN(rmn_bits, nbits)) > 0) |
| 1895 | 1895 | put_bits(pb, rmn_bits, get_bits(gb, rmn_bits)); |
| 1896 | − ff_copy_bits(pb, data + size - rmn_bytes, | |
| 1896 | + avpriv_copy_bits(pb, data + size - rmn_bytes, | |
| 1897 | 1897 | FFMIN(nbits - rmn_bits, rmn_bytes << 3)); |
| 1898 | 1898 | } |
| 1899 | 1899 | |
| @@ -50,9 +50,9 @@ extern void ff_ac3_extract_exponents_ssse3(uint8_t *exp, int32_t *coef, int nb_c · 49 unmodified lines | ||
| 50 | 50 | |
| 51 | 51 | av_cold void ff_ac3dsp_init_x86(AC3DSPContext *c, int bit_exact) |
| 52 | 52 | { |
| 53 | +#if HAVE_YASM | |
| 53 | 54 | int mm_flags = av_get_cpu_flags(); |
| 54 | 55 | |
| 55 | −#if HAVE_YASM | |
| 56 | 56 | if (mm_flags & AV_CPU_FLAG_MMX) { |
| 57 | 57 | c->ac3_exponent_min = ff_ac3_exponent_min_mmx; |
| 58 | 58 | c->ac3_max_msb_abs_int16 = ff_ac3_max_msb_abs_int16_mmx; |
| @@ -169,9 +169,9 @@ void ff_pred4x4_vertical_vp8_mmxext(uint8_t *src, const uint8_t *topright, int s · 168 unmodified lines | ||
| 169 | 169 | |
| 170 | 170 | void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc) |
| 171 | 171 | { |
| 172 | +#if HAVE_YASM | |
| 172 | 173 | int mm_flags = av_get_cpu_flags(); |
| 173 | 174 | |
| 174 | −#if HAVE_YASM | |
| 175 | 175 | if (bit_depth == 8) { |
| 176 | 176 | if (mm_flags & AV_CPU_FLAG_MMX) { |
| 177 | 177 | h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vertical_mmx; |
| @@ -52,6 +52,6 @@ void ff_proresdsp_x86_init(ProresDSPContext *dsp, AVCodecContext *avctx) · 51 unmodified lines | ||
| 52 | 52 | dsp->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM; |
| 53 | 53 | dsp->idct_put = ff_prores_idct_put_10_avx; |
| 54 | 54 | } |
| 55 | −#endif | |
| 56 | −#endif | |
| 55 | +#endif /* HAVE_AVX */ | |
| 56 | +#endif /* ARCH_X86_64 && HAVE_YASM */ | |
| 57 | 57 | } |
| @@ -283,9 +283,9 @@ DECLARE_LOOP_FILTER(sse4) · 282 unmodified lines | ||
| 283 | 283 | |
| 284 | 284 | av_cold void ff_vp8dsp_init_x86(VP8DSPContext* c) |
| 285 | 285 | { |
| 286 | +#if HAVE_YASM | |
| 286 | 287 | int mm_flags = av_get_cpu_flags(); |
| 287 | 288 | |
| 288 | −#if HAVE_YASM | |
| 289 | 289 | if (mm_flags & AV_CPU_FLAG_MMX) { |
| 290 | 290 | c->vp8_idct_dc_add = ff_vp8_idct_dc_add_mmx; |
| 291 | 291 | c->vp8_idct_dc_add4y = ff_vp8_idct_dc_add4y_mmx; |
| @@ -21,7 +21,7 @@ · 20 unmodified lines | ||
| 21 | 21 | #include "libavutil/intreadwrite.h" |
| 22 | 22 | #include "xiph.h" |
| 23 | 23 | |
| 24 | −int ff_split_xiph_headers(uint8_t *extradata, int extradata_size, | |
| 24 | +int avpriv_split_xiph_headers(uint8_t *extradata, int extradata_size, | |
| 25 | 25 | int first_header_size, uint8_t *header_start[3], |
| 26 | 26 | int header_len[3]) |
| 27 | 27 | { |
| @@ -36,8 +36,8 @@ · 35 unmodified lines | ||
| 36 | 36 | * @param[out] header_len The sizes of each of the three headers. |
| 37 | 37 | * @return On error a negative value is returned, on success zero. |
| 38 | 38 | */ |
| 39 | −int ff_split_xiph_headers(uint8_t *extradata, int extradata_size, | |
| 40 | − int first_header_size, uint8_t *header_start[3], | |
| 41 | − int header_len[3]); | |
| 39 | +int avpriv_split_xiph_headers(uint8_t *extradata, int extradata_size, | |
| 40 | + int first_header_size, uint8_t *header_start[3], | |
| 41 | + int header_len[3]); | |
| 42 | 42 | |
| 43 | 43 | #endif /* AVCODEC_XIPH_H */ |
| @@ -90,7 +90,7 @@ static int xsub_encode_rle(PutBitContext *pb, const uint8_t *bitmap, · 89 unmodified lines | ||
| 90 | 90 | if (color != PADDING_COLOR && (PADDING + (w&1))) |
| 91 | 91 | put_xsub_rle(pb, PADDING + (w&1), PADDING_COLOR); |
| 92 | 92 | |
| 93 | − align_put_bits(pb); | |
| 93 | + avpriv_align_put_bits(pb); | |
| 94 | 94 | |
| 95 | 95 | bitmap += linesize; |
| 96 | 96 | } |
| @@ -194,7 +194,7 @@ static int xsub_encode(AVCodecContext *avctx, unsigned char *buf, · 97 unmodified lines | ||
| 194 | 194 | // Enforce total height to be be multiple of 2 |
| 195 | 195 | if (h->rects[0]->h & 1) { |
| 196 | 196 | put_xsub_rle(&pb, h->rects[0]->w, PADDING_COLOR); |
| 197 | − align_put_bits(&pb); | |
| 197 | + avpriv_align_put_bits(&pb); | |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | flush_put_bits(&pb); |
| @@ -86,7 +86,7 @@ static int dv1394_read_header(AVFormatContext * context, AVFormatParameters * ap · 85 unmodified lines | ||
| 86 | 86 | { |
| 87 | 87 | struct dv1394_data *dv = context->priv_data; |
| 88 | 88 | |
| 89 | − dv->dv_demux = dv_init_demux(context); | |
| 89 | + dv->dv_demux = avpriv_dv_init_demux(context); | |
| 90 | 90 | if (!dv->dv_demux) |
| 91 | 91 | goto failed; |
| 92 | 92 | |
| @@ -124,7 +124,7 @@ static int dv1394_read_packet(AVFormatContext *context, AVPacket *pkt) · 31 unmodified lines | ||
| 124 | 124 | struct dv1394_data *dv = context->priv_data; |
| 125 | 125 | int size; |
| 126 | 126 | |
| 127 | − size = dv_get_packet(dv->dv_demux, pkt); | |
| 127 | + size = avpriv_dv_get_packet(dv->dv_demux, pkt); | |
| 128 | 128 | if (size > 0) |
| 129 | 129 | return size; |
| 130 | 130 | |
| @@ -186,7 +186,7 @@ restart_poll: · 55 unmodified lines | ||
| 186 | 186 | av_dlog(context, "index %d, avail %d, done %d\n", dv->index, dv->avail, |
| 187 | 187 | dv->done); |
| 188 | 188 | |
| 189 | − size = dv_produce_packet(dv->dv_demux, pkt, | |
| 189 | + size = avpriv_dv_produce_packet(dv->dv_demux, pkt, | |
| 190 | 190 | dv->ring + (dv->index * DV1394_PAL_FRAME_SIZE), |
| 191 | 191 | DV1394_PAL_FRAME_SIZE, -1); |
| 192 | 192 | dv->index = (dv->index + 1) % DV1394_RING_FRAMES; |
| @@ -98,7 +98,7 @@ static av_cold int read_header(AVFormatContext *ctx, AVFormatParameters *ap) · 97 unmodified lines | ||
| 98 | 98 | for (i = 0; i < s->drive->tracks; i++) { |
| 99 | 99 | char title[16]; |
| 100 | 100 | snprintf(title, sizeof(title), "track %02d", s->drive->disc_toc[i].bTrack); |
| 101 | − ff_new_chapter(ctx, i, st->time_base, s->drive->disc_toc[i].dwStartSector, | |
| 101 | + avpriv_new_chapter(ctx, i, st->time_base, s->drive->disc_toc[i].dwStartSector, | |
| 102 | 102 | s->drive->disc_toc[i+1].dwStartSector, title); |
| 103 | 103 | } |
| 104 | 104 | |
| @@ -41,7 +41,7 @@ static int ac3_eac3_probe(AVProbeData *p, enum CodecID expected_codec_id) · 40 unmodified lines | ||
| 41 | 41 | |
| 42 | 42 | for(frames = 0; buf2 < end; frames++) { |
| 43 | 43 | init_get_bits(&gbc, buf2, 54); |
| 44 | − if(ff_ac3_parse_header(&gbc, &hdr) < 0) | |
| 44 | + if(avpriv_ac3_parse_header(&gbc, &hdr) < 0) | |
| 45 | 45 | break; |
| 46 | 46 | if(buf2 + hdr.frame_size > end || |
| 47 | 47 | av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, buf2 + 2, hdr.frame_size - 2)) |
| @@ -35,7 +35,7 @@ int ff_adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, uint8_t *buf · 34 unmodified lines | ||
| 35 | 35 | int off; |
| 36 | 36 | |
| 37 | 37 | init_get_bits(&gb, buf, size * 8); |
| 38 | − off = ff_mpeg4audio_get_config(&m4ac, buf, size); | |
| 38 | + off = avpriv_mpeg4audio_get_config(&m4ac, buf, size); | |
| 39 | 39 | if (off < 0) |
| 40 | 40 | return off; |
| 41 | 41 | skip_bits_long(&gb, off); |
| @@ -67,7 +67,7 @@ int ff_adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, uint8_t *buf · 25 unmodified lines | ||
| 67 | 67 | init_put_bits(&pb, adts->pce_data, MAX_PCE_SIZE); |
| 68 | 68 | |
| 69 | 69 | put_bits(&pb, 3, 5); //ID_PCE |
| 70 | − adts->pce_size = (ff_copy_pce_data(&pb, &gb) + 3) / 8; | |
| 70 | + adts->pce_size = (avpriv_copy_pce_data(&pb, &gb) + 3) / 8; | |
| 71 | 71 | flush_put_bits(&pb); |
| 72 | 72 | } |
| 73 | 73 | |
| @@ -569,7 +569,7 @@ static int asf_read_marker(AVFormatContext *s, int64_t size) · 568 unmodified lines | ||
| 569 | 569 | name_len = avio_rl32(pb); // name length |
| 570 | 570 | if ((ret = avio_get_str16le(pb, name_len * 2, name, sizeof(name))) < name_len) |
| 571 | 571 | avio_skip(pb, name_len - ret); |
| 572 | − ff_new_chapter(s, i, (AVRational){1, 10000000}, pres_time, AV_NOPTS_VALUE, name ); | |
| 572 | + avpriv_new_chapter(s, i, (AVRational){1, 10000000}, pres_time, AV_NOPTS_VALUE, name ); | |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | return 0; |
| @@ -490,7 +490,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) · 489 unmodified lines | ||
| 490 | 490 | av_freep(&s->streams[0]); |
| 491 | 491 | s->nb_streams = 0; |
| 492 | 492 | if (CONFIG_DV_DEMUXER) { |
| 493 | − avi->dv_demux = dv_init_demux(s); | |
| 493 | + avi->dv_demux = avpriv_dv_init_demux(s); | |
| 494 | 494 | if (!avi->dv_demux) |
| 495 | 495 | goto fail; |
| 496 | 496 | } |
| @@ -1012,7 +1012,7 @@ static int avi_read_packet(AVFormatContext *s, AVPacket *pkt) · 515 unmodified lines | ||
| 1012 | 1012 | void* dstr; |
| 1013 | 1013 | |
| 1014 | 1014 | if (CONFIG_DV_DEMUXER && avi->dv_demux) { |
| 1015 | − int size = dv_get_packet(avi->dv_demux, pkt); | |
| 1015 | + int size = avpriv_dv_get_packet(avi->dv_demux, pkt); | |
| 1016 | 1016 | if (size >= 0) |
| 1017 | 1017 | return size; |
| 1018 | 1018 | } |
| @@ -1115,7 +1115,7 @@ resync: · 96 unmodified lines | ||
| 1115 | 1115 | |
| 1116 | 1116 | if (CONFIG_DV_DEMUXER && avi->dv_demux) { |
| 1117 | 1117 | dstr = pkt->destruct; |
| 1118 | − size = dv_produce_packet(avi->dv_demux, pkt, | |
| 1118 | + size = avpriv_dv_produce_packet(avi->dv_demux, pkt, | |
| 1119 | 1119 | pkt->data, pkt->size, pkt->pos); |
| 1120 | 1120 | pkt->destruct = dstr; |
| 1121 | 1121 | pkt->flags |= AV_PKT_FLAG_KEY; |
| @@ -270,7 +270,7 @@ static int dv_extract_video_info(DVDemuxContext *c, uint8_t* frame) · 269 unmodified lines | ||
| 270 | 270 | * The following 3 functions constitute our interface to the world |
| 271 | 271 | */ |
| 272 | 272 | |
| 273 | −DVDemuxContext* dv_init_demux(AVFormatContext *s) | |
| 273 | +DVDemuxContext* avpriv_dv_init_demux(AVFormatContext *s) | |
| 274 | 274 | { |
| 275 | 275 | DVDemuxContext *c; |
| 276 | 276 | |
| @@ -299,7 +299,7 @@ DVDemuxContext* dv_init_demux(AVFormatContext *s) · 22 unmodified lines | ||
| 299 | 299 | return c; |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | −int dv_get_packet(DVDemuxContext *c, AVPacket *pkt) | |
| 302 | +int avpriv_dv_get_packet(DVDemuxContext *c, AVPacket *pkt) | |
| 303 | 303 | { |
| 304 | 304 | int size = -1; |
| 305 | 305 | int i; |
| @@ -316,14 +316,14 @@ int dv_get_packet(DVDemuxContext *c, AVPacket *pkt) · 10 unmodified lines | ||
| 316 | 316 | return size; |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | −int dv_produce_packet(DVDemuxContext *c, AVPacket *pkt, | |
| 319 | +int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt, | |
| 320 | 320 | uint8_t* buf, int buf_size, int64_t pos) |
| 321 | 321 | { |
| 322 | 322 | int size, i; |
| 323 | 323 | uint8_t *ppcm[4] = {0}; |
| 324 | 324 | |
| 325 | 325 | if (buf_size < DV_PROFILE_BYTES || |
| 326 | − !(c->sys = ff_dv_frame_profile(c->sys, buf, buf_size)) || | |
| 326 | + !(c->sys = avpriv_dv_frame_profile(c->sys, buf, buf_size)) || | |
| 327 | 327 | buf_size < c->sys->frame_size) { |
| 328 | 328 | return -1; /* Broken frame, or not enough data */ |
| 329 | 329 | } |
| @@ -371,7 +371,7 @@ static int64_t dv_frame_offset(AVFormatContext *s, DVDemuxContext *c, · 41 unmodified lines | ||
| 371 | 371 | int64_t timestamp, int flags) |
| 372 | 372 | { |
| 373 | 373 | // FIXME: sys may be wrong if last dv_read_packet() failed (buffer is junk) |
| 374 | − const DVprofile* sys = ff_dv_codec_profile(c->vst->codec); | |
| 374 | + const DVprofile* sys = avpriv_dv_codec_profile(c->vst->codec); | |
| 375 | 375 | int64_t offset; |
| 376 | 376 | int64_t size = avio_size(s->pb) - s->data_offset; |
| 377 | 377 | int64_t max_offset = ((size-1) / sys->frame_size) * sys->frame_size; |
| @@ -409,7 +409,7 @@ static int dv_read_header(AVFormatContext *s, · 31 unmodified lines | ||
| 409 | 409 | unsigned state, marker_pos = 0; |
| 410 | 410 | RawDVContext *c = s->priv_data; |
| 411 | 411 | |
| 412 | − c->dv_demux = dv_init_demux(s); | |
| 412 | + c->dv_demux = avpriv_dv_init_demux(s); | |
| 413 | 413 | if (!c->dv_demux) |
| 414 | 414 | return -1; |
| 415 | 415 | |
| @@ -434,7 +434,7 @@ static int dv_read_header(AVFormatContext *s, · 18 unmodified lines | ||
| 434 | 434 | avio_seek(s->pb, -DV_PROFILE_BYTES, SEEK_CUR) < 0) |
| 435 | 435 | return AVERROR(EIO); |
| 436 | 436 | |
| 437 | − c->dv_demux->sys = ff_dv_frame_profile(c->dv_demux->sys, c->buf, DV_PROFILE_BYTES); | |
| 437 | + c->dv_demux->sys = avpriv_dv_frame_profile(c->dv_demux->sys, c->buf, DV_PROFILE_BYTES); | |
| 438 | 438 | if (!c->dv_demux->sys) { |
| 439 | 439 | av_log(s, AV_LOG_ERROR, "Can't determine profile of DV input stream.\n"); |
| 440 | 440 | return -1; |
| @@ -452,7 +452,7 @@ static int dv_read_packet(AVFormatContext *s, AVPacket *pkt) · 11 unmodified lines | ||
| 452 | 452 | int size; |
| 453 | 453 | RawDVContext *c = s->priv_data; |
| 454 | 454 | |
| 455 | − size = dv_get_packet(c->dv_demux, pkt); | |
| 455 | + size = avpriv_dv_get_packet(c->dv_demux, pkt); | |
| 456 | 456 | |
| 457 | 457 | if (size < 0) { |
| 458 | 458 | int64_t pos = avio_tell(s->pb); |
| @@ -462,7 +462,7 @@ static int dv_read_packet(AVFormatContext *s, AVPacket *pkt) · 3 unmodified lines | ||
| 462 | 462 | if (avio_read(s->pb, c->buf, size) <= 0) |
| 463 | 463 | return AVERROR(EIO); |
| 464 | 464 | |
| 465 | − size = dv_produce_packet(c->dv_demux, pkt, c->buf, size, pos); | |
| 465 | + size = avpriv_dv_produce_packet(c->dv_demux, pkt, c->buf, size, pos); | |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | return size; |
| @@ -31,9 +31,9 @@ · 30 unmodified lines | ||
| 31 | 31 | #include "avformat.h" |
| 32 | 32 | |
| 33 | 33 | typedef struct DVDemuxContext DVDemuxContext; |
| 34 | −DVDemuxContext* dv_init_demux(AVFormatContext* s); | |
| 35 | −int dv_get_packet(DVDemuxContext*, AVPacket *); | |
| 36 | −int dv_produce_packet(DVDemuxContext*, AVPacket*, uint8_t*, int, int64_t); | |
| 34 | +DVDemuxContext* avpriv_dv_init_demux(AVFormatContext* s); | |
| 35 | +int avpriv_dv_get_packet(DVDemuxContext*, AVPacket *); | |
| 36 | +int avpriv_dv_produce_packet(DVDemuxContext*, AVPacket*, uint8_t*, int, int64_t); | |
| 37 | 37 | void dv_offset_reset(DVDemuxContext *c, int64_t frame_offset); |
| 38 | 38 | |
| 39 | 39 | typedef struct DVMuxContext DVMuxContext; |
| @@ -320,7 +320,7 @@ static DVMuxContext* dv_init_mux(AVFormatContext* s) · 319 unmodified lines | ||
| 320 | 320 | c->ast[i]->codec->channels != 2)) |
| 321 | 321 | goto bail_out; |
| 322 | 322 | } |
| 323 | − c->sys = ff_dv_codec_profile(vst->codec); | |
| 323 | + c->sys = avpriv_dv_codec_profile(vst->codec); | |
| 324 | 324 | if (!c->sys) |
| 325 | 325 | goto bail_out; |
| 326 | 326 | |
| @@ -75,7 +75,7 @@ static AVChapter *read_chapter(AVFormatContext *s) · 74 unmodified lines | ||
| 75 | 75 | end = AV_NOPTS_VALUE; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | − return ff_new_chapter(s, s->nb_chapters, tb, start, end, NULL); | |
| 78 | + return avpriv_new_chapter(s, s->nb_chapters, tb, start, end, NULL); | |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | static uint8_t *unescape(uint8_t *buf, int size) |
| @@ -48,7 +48,7 @@ static int flac_read_header(AVFormatContext *s, · 47 unmodified lines | ||
| 48 | 48 | /* process metadata blocks */ |
| 49 | 49 | while (!url_feof(s->pb) && !metadata_last) { |
| 50 | 50 | avio_read(s->pb, header, 4); |
| 51 | − ff_flac_parse_block_header(header, &metadata_last, &metadata_type, | |
| 51 | + avpriv_flac_parse_block_header(header, &metadata_last, &metadata_type, | |
| 52 | 52 | &metadata_size); |
| 53 | 53 | switch (metadata_type) { |
| 54 | 54 | /* allocate and read metadata block for supported types */ |
| @@ -87,7 +87,7 @@ static int flac_read_header(AVFormatContext *s, · 32 unmodified lines | ||
| 87 | 87 | buffer = NULL; |
| 88 | 88 | |
| 89 | 89 | /* get codec params from STREAMINFO header */ |
| 90 | − ff_flac_parse_streaminfo(st->codec, &si, st->codec->extradata); | |
| 90 | + avpriv_flac_parse_streaminfo(st->codec, &si, st->codec->extradata); | |
| 91 | 91 | |
| 92 | 92 | /* set time base and duration */ |
| 93 | 93 | if (si.samplerate > 0) { |
| @@ -94,7 +94,7 @@ static int flac_write_trailer(struct AVFormatContext *s) · 93 unmodified lines | ||
| 94 | 94 | enum FLACExtradataFormat format; |
| 95 | 95 | int64_t file_size; |
| 96 | 96 | |
| 97 | − if (!ff_flac_is_extradata_valid(s->streams[0]->codec, &format, &streaminfo)) | |
| 97 | + if (!avpriv_flac_is_extradata_valid(s->streams[0]->codec, &format, &streaminfo)) | |
| 98 | 98 | return -1; |
| 99 | 99 | |
| 100 | 100 | if (pb->seekable) { |
| @@ -34,7 +34,7 @@ int ff_flac_write_header(AVIOContext *pb, AVCodecContext *codec, · 33 unmodified lines | ||
| 34 | 34 | enum FLACExtradataFormat format; |
| 35 | 35 | |
| 36 | 36 | header[4] = last_block ? 0x80 : 0x00; |
| 37 | − if (!ff_flac_is_extradata_valid(codec, &format, &streaminfo)) | |
| 37 | + if (!avpriv_flac_is_extradata_valid(codec, &format, &streaminfo)) | |
| 38 | 38 | return -1; |
| 39 | 39 | |
| 40 | 40 | /* write "fLaC" stream marker and first metadata block header if needed */ |
| @@ -542,7 +542,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) · 541 unmodified lines | ||
| 542 | 542 | return ret; |
| 543 | 543 | if (st->codec->codec_id == CODEC_ID_AAC) { |
| 544 | 544 | MPEG4AudioConfig cfg; |
| 545 | − ff_mpeg4audio_get_config(&cfg, st->codec->extradata, | |
| 545 | + avpriv_mpeg4audio_get_config(&cfg, st->codec->extradata, | |
| 546 | 546 | st->codec->extradata_size); |
| 547 | 547 | st->codec->channels = cfg.channels; |
| 548 | 548 | if (cfg.ext_sample_rate) |
| @@ -61,7 +61,7 @@ typedef struct FLVContext { · 60 unmodified lines | ||
| 61 | 61 | int64_t filesize_offset; |
| 62 | 62 | int64_t duration; |
| 63 | 63 | int delay; ///< first dts delay for AVC |
| 64 | − int64_t last_video_ts; | |
| 64 | + int64_t last_ts; | |
| 65 | 65 | } FLVContext; |
| 66 | 66 | |
| 67 | 67 | static int get_audio_flags(AVCodecContext *enc){ |
| @@ -78,11 +78,6 @@ static int get_audio_flags(AVCodecContext *enc){ · 10 unmodified lines | ||
| 78 | 78 | av_log(enc, AV_LOG_ERROR, "flv only supports mono Speex audio\n"); |
| 79 | 79 | return -1; |
| 80 | 80 | } |
| 81 | − if (enc->frame_size / 320 > 8) { | |
| 82 | − av_log(enc, AV_LOG_WARNING, "Warning: Speex stream has more than " | |
| 83 | − "8 frames per packet. Adobe Flash " | |
| 84 | − "Player cannot handle this!\n"); | |
| 85 | − } | |
| 86 | 81 | return FLV_CODECID_SPEEX | FLV_SAMPLERATE_11025HZ | FLV_SAMPLESSIZE_16BIT; |
| 87 | 82 | } else { |
| 88 | 83 | switch (enc->sample_rate) { |
| @@ -223,7 +218,7 @@ static int flv_write_header(AVFormatContext *s) · 134 unmodified lines | ||
| 223 | 218 | } |
| 224 | 219 | } |
| 225 | 220 | |
| 226 | − flv->last_video_ts = -1; | |
| 221 | + flv->last_ts = -1; | |
| 227 | 222 | |
| 228 | 223 | /* write meta_tag */ |
| 229 | 224 | avio_w8(pb, 18); // tag type META |
| @@ -368,7 +363,7 @@ static int flv_write_trailer(AVFormatContext *s) · 138 unmodified lines | ||
| 368 | 363 | AVCodecContext *enc = s->streams[i]->codec; |
| 369 | 364 | if (enc->codec_type == AVMEDIA_TYPE_VIDEO && |
| 370 | 365 | (enc->codec_id == CODEC_ID_H264 || enc->codec_id == CODEC_ID_MPEG4)) { |
| 371 | − put_avc_eos_tag(pb, flv->last_video_ts); | |
| 366 | + put_avc_eos_tag(pb, flv->last_ts); | |
| 372 | 367 | } |
| 373 | 368 | } |
| 374 | 369 | |
| @@ -434,19 +429,26 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) · 59 unmodified lines | ||
| 434 | 429 | if (ff_avc_parse_nal_units_buf(pkt->data, &data, &size) < 0) |
| 435 | 430 | return -1; |
| 436 | 431 | } |
| 437 | − if (!flv->delay && pkt->dts < 0) | |
| 438 | − flv->delay = -pkt->dts; | |
| 439 | 432 | } else if (enc->codec_id == CODEC_ID_AAC && pkt->size > 2 && |
| 440 | 433 | (AV_RB16(pkt->data) & 0xfff0) == 0xfff0) { |
| 441 | 434 | av_log(s, AV_LOG_ERROR, "malformated aac bitstream, use -absf aac_adtstoasc\n"); |
| 442 | 435 | return -1; |
| 443 | 436 | } |
| 437 | + if (!flv->delay && pkt->dts < 0) | |
| 438 | + flv->delay = -pkt->dts; | |
| 444 | 439 | |
| 445 | 440 | ts = pkt->dts + flv->delay; // add delay to force positive dts |
| 446 | − if (enc->codec_type == AVMEDIA_TYPE_VIDEO) { | |
| 447 | − if (flv->last_video_ts < ts) | |
| 448 | − flv->last_video_ts = ts; | |
| 441 | + | |
| 442 | + /* check Speex packet duration */ | |
| 443 | + if (enc->codec_id == CODEC_ID_SPEEX && ts - flv->last_ts > 160) { | |
| 444 | + av_log(s, AV_LOG_WARNING, "Warning: Speex stream has more than " | |
| 445 | + "8 frames per packet. Adobe Flash " | |
| 446 | + "Player cannot handle this!\n"); | |
| 449 | 447 | } |
| 448 | + | |
| 449 | + if (flv->last_ts < ts) | |
| 450 | + flv->last_ts = ts; | |
| 451 | + | |
| 450 | 452 | avio_wb24(pb,size + flags_size); |
| 451 | 453 | avio_wb24(pb,ts); |
| 452 | 454 | avio_w8(pb,(ts >> 24) & 0x7F); // timestamps are 32bits _signed_ |
| @@ -185,9 +185,9 @@ static void gxf_material_tags(AVIOContext *pb, int *len, struct gxf_stream_info · 184 unmodified lines | ||
| 185 | 185 | * @return fps as AVRational, or 0 / 0 if unknown |
| 186 | 186 | */ |
| 187 | 187 | static AVRational fps_tag2avr(int32_t fps) { |
| 188 | − extern const AVRational ff_frame_rate_tab[]; | |
| 188 | + extern const AVRational avpriv_frame_rate_tab[]; | |
| 189 | 189 | if (fps < 1 || fps > 9) fps = 9; |
| 190 | − return ff_frame_rate_tab[9 - fps]; // values have opposite order | |
| 190 | + return avpriv_frame_rate_tab[9 - fps]; // values have opposite order | |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | /** |
| @@ -223,8 +223,8 @@ int ff_add_index_entry(AVIndexEntry **index_entries, · 222 unmodified lines | ||
| 223 | 223 | * |
| 224 | 224 | * @return AVChapter or NULL on error |
| 225 | 225 | */ |
| 226 | −AVChapter *ff_new_chapter(AVFormatContext *s, int id, AVRational time_base, | |
| 227 | − int64_t start, int64_t end, const char *title); | |
| 226 | +AVChapter *avpriv_new_chapter(AVFormatContext *s, int id, AVRational time_base, | |
| 227 | + int64_t start, int64_t end, const char *title); | |
| 228 | 228 | |
| 229 | 229 | /** |
| 230 | 230 | * Ensure the index uses less memory than the maximum specified in |
| @@ -433,11 +433,11 @@ int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext · 432 unmodified lines | ||
| 433 | 433 | st->codec->extradata_size = len; |
| 434 | 434 | if (st->codec->codec_id == CODEC_ID_AAC) { |
| 435 | 435 | MPEG4AudioConfig cfg; |
| 436 | − ff_mpeg4audio_get_config(&cfg, st->codec->extradata, | |
| 436 | + avpriv_mpeg4audio_get_config(&cfg, st->codec->extradata, | |
| 437 | 437 | st->codec->extradata_size); |
| 438 | 438 | st->codec->channels = cfg.channels; |
| 439 | 439 | if (cfg.object_type == 29 && cfg.sampling_index < 3) // old mp3on4 |
| 440 | − st->codec->sample_rate = ff_mpa_freq_tab[cfg.sampling_index]; | |
| 440 | + st->codec->sample_rate = avpriv_mpa_freq_tab[cfg.sampling_index]; | |
| 441 | 441 | else if (cfg.ext_sample_rate) |
| 442 | 442 | st->codec->sample_rate = cfg.ext_sample_rate; |
| 443 | 443 | else |
| @@ -55,7 +55,7 @@ static int latm_decode_extradata(LATMContext *ctx, uint8_t *buf, int size) · 54 unmodified lines | ||
| 55 | 55 | MPEG4AudioConfig m4ac; |
| 56 | 56 | |
| 57 | 57 | init_get_bits(&gb, buf, size * 8); |
| 58 | − ctx->off = ff_mpeg4audio_get_config(&m4ac, buf, size); | |
| 58 | + ctx->off = avpriv_mpeg4audio_get_config(&m4ac, buf, size); | |
| 59 | 59 | if (ctx->off < 0) |
| 60 | 60 | return ctx->off; |
| 61 | 61 | skip_bits_long(&gb, ctx->off); |
| @@ -110,12 +110,12 @@ static int latm_write_frame_header(AVFormatContext *s, PutBitContext *bs) · 48 unmodified lines | ||
| 110 | 110 | /* AudioSpecificConfig */ |
| 111 | 111 | if (ctx->object_type == AOT_ALS) { |
| 112 | 112 | header_size = avctx->extradata_size-(ctx->off + 7) >> 3; |
| 113 | − ff_copy_bits(bs, &avctx->extradata[ctx->off], header_size); | |
| 113 | + avpriv_copy_bits(bs, &avctx->extradata[ctx->off], header_size); | |
| 114 | 114 | } else { |
| 115 | − ff_copy_bits(bs, avctx->extradata, ctx->off + 3); | |
| 115 | + avpriv_copy_bits(bs, avctx->extradata, ctx->off + 3); | |
| 116 | 116 | |
| 117 | 117 | if (!ctx->channel_conf) { |
| 118 | − ff_copy_pce_data(bs, &gb); | |
| 118 | + avpriv_copy_pce_data(bs, &gb); | |
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | |
| @@ -168,7 +168,7 @@ static int latm_write_packet(AVFormatContext *s, AVPacket *pkt) · 46 unmodified lines | ||
| 168 | 168 | for (i = 0; i < pkt->size; i++) |
| 169 | 169 | put_bits(&bs, 8, pkt->data[i]); |
| 170 | 170 | |
| 171 | − align_put_bits(&bs); | |
| 171 | + avpriv_align_put_bits(&bs); | |
| 172 | 172 | flush_put_bits(&bs); |
| 173 | 173 | |
| 174 | 174 | len = put_bits_count(&bs) >> 3; |
| @@ -1,7 +1,23 @@ | ||
| 1 | 1 | LIBAVFORMAT_$MAJOR { |
| 2 | − global: *; | |
| 3 | − local: | |
| 4 | − ff_*_demuxer; | |
| 5 | − ff_*_muxer; | |
| 6 | − ff_*_protocol; | |
| 2 | + global: av*; | |
| 3 | + #FIXME those are for avserver | |
| 4 | + ff_inet_aton; | |
| 5 | + ff_socket_nonblock; | |
| 6 | + ffm_set_write_index; | |
| 7 | + ffm_read_write_index; | |
| 8 | + ffm_write_write_index; | |
| 9 | + ff_rtsp_parse_line; | |
| 10 | + ff_rtp_get_local_rtp_port; | |
| 11 | + ff_rtp_get_local_rtcp_port; | |
| 12 | + ffio_open_dyn_packet_buf; | |
| 13 | + url_open; | |
| 14 | + url_close; | |
| 15 | + url_write; | |
| 16 | + url_get_max_packet_size; | |
| 17 | + #those are deprecated, remove on next bump | |
| 18 | + find_info_tag; | |
| 19 | + parse_date; | |
| 20 | + dump_format; | |
| 21 | + url_*; | |
| 22 | + local: *; | |
| 7 | 23 | }; |
| @@ -1303,8 +1303,8 @@ static int matroska_aac_sri(int samplerate) · 1302 unmodified lines | ||
| 1303 | 1303 | { |
| 1304 | 1304 | int sri; |
| 1305 | 1305 | |
| 1306 | − for (sri=0; sri<FF_ARRAY_ELEMS(ff_mpeg4audio_sample_rates); sri++) | |
| 1307 | − if (ff_mpeg4audio_sample_rates[sri] == samplerate) | |
| 1306 | + for (sri=0; sri<FF_ARRAY_ELEMS(avpriv_mpeg4audio_sample_rates); sri++) | |
| 1307 | + if (avpriv_mpeg4audio_sample_rates[sri] == samplerate) | |
| 1308 | 1308 | break; |
| 1309 | 1309 | return sri; |
| 1310 | 1310 | } |
| @@ -1668,7 +1668,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap) · 357 unmodified lines | ||
| 1668 | 1668 | if (chapters[i].start != AV_NOPTS_VALUE && chapters[i].uid |
| 1669 | 1669 | && (max_start==0 || chapters[i].start > max_start)) { |
| 1670 | 1670 | chapters[i].chapter = |
| 1671 | − ff_new_chapter(s, chapters[i].uid, (AVRational){1, 1000000000}, | |
| 1671 | + avpriv_new_chapter(s, chapters[i].uid, (AVRational){1, 1000000000}, | |
| 1672 | 1672 | chapters[i].start, chapters[i].end, |
| 1673 | 1673 | chapters[i].title); |
| 1674 | 1674 | av_dict_set(&chapters[i].chapter->metadata, |
| @@ -423,7 +423,7 @@ static int put_xiph_codecpriv(AVFormatContext *s, AVIOContext *pb, AVCodecContex · 422 unmodified lines | ||
| 423 | 423 | else |
| 424 | 424 | first_header_size = 42; |
| 425 | 425 | |
| 426 | − if (ff_split_xiph_headers(codec->extradata, codec->extradata_size, | |
| 426 | + if (avpriv_split_xiph_headers(codec->extradata, codec->extradata_size, | |
| 427 | 427 | first_header_size, header_start, header_len) < 0) { |
| 428 | 428 | av_log(s, AV_LOG_ERROR, "Extradata corrupt.\n"); |
| 429 | 429 | return -1; |
| @@ -443,7 +443,7 @@ static void get_aac_sample_rates(AVFormatContext *s, AVCodecContext *codec, int · 13 unmodified lines | ||
| 443 | 443 | { |
| 444 | 444 | MPEG4AudioConfig mp4ac; |
| 445 | 445 | |
| 446 | − if (ff_mpeg4audio_get_config(&mp4ac, codec->extradata, codec->extradata_size) < 0) { | |
| 446 | + if (avpriv_mpeg4audio_get_config(&mp4ac, codec->extradata, codec->extradata_size) < 0) { | |
| 447 | 447 | av_log(s, AV_LOG_WARNING, "Error parsing AAC extradata, unable to determine samplerate.\n"); |
| 448 | 448 | return; |
| 449 | 449 | } |
| @@ -289,7 +289,7 @@ static int mov_read_chpl(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 288 unmodified lines | ||
| 289 | 289 | |
| 290 | 290 | avio_read(pb, str, str_len); |
| 291 | 291 | str[str_len] = 0; |
| 292 | − ff_new_chapter(c->fc, i, (AVRational){1,10000000}, start, AV_NOPTS_VALUE, str); | |
| 292 | + avpriv_new_chapter(c->fc, i, (AVRational){1,10000000}, start, AV_NOPTS_VALUE, str); | |
| 293 | 293 | } |
| 294 | 294 | return 0; |
| 295 | 295 | } |
| @@ -1291,7 +1291,7 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries) · 995 unmodified lines | ||
| 1291 | 1291 | #if CONFIG_DV_DEMUXER |
| 1292 | 1292 | case CODEC_ID_DVAUDIO: |
| 1293 | 1293 | c->dv_fctx = avformat_alloc_context(); |
| 1294 | − c->dv_demux = dv_init_demux(c->dv_fctx); | |
| 1294 | + c->dv_demux = avpriv_dv_init_demux(c->dv_fctx); | |
| 1295 | 1295 | if (!c->dv_demux) { |
| 1296 | 1296 | av_log(c->fc, AV_LOG_ERROR, "dv demux context init error\n"); |
| 1297 | 1297 | return -1; |
| @@ -2484,7 +2484,7 @@ static void mov_read_chapters(AVFormatContext *s) · 1186 unmodified lines | ||
| 2484 | 2484 | } |
| 2485 | 2485 | } |
| 2486 | 2486 | |
| 2487 | − ff_new_chapter(s, i, st->time_base, sample->timestamp, end, title); | |
| 2487 | + avpriv_new_chapter(s, i, st->time_base, sample->timestamp, end, title); | |
| 2488 | 2488 | av_freep(&title); |
| 2489 | 2489 | } |
| 2490 | 2490 | finish: |
| @@ -2592,10 +2592,10 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) · 101 unmodified lines | ||
| 2592 | 2592 | } |
| 2593 | 2593 | #if CONFIG_DV_DEMUXER |
| 2594 | 2594 | if (mov->dv_demux && sc->dv_audio_container) { |
| 2595 | − dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); | |
| 2595 | + avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); | |
| 2596 | 2596 | av_free(pkt->data); |
| 2597 | 2597 | pkt->size = 0; |
| 2598 | − ret = dv_get_packet(mov->dv_demux, pkt); | |
| 2598 | + ret = avpriv_dv_get_packet(mov->dv_demux, pkt); | |
| 2599 | 2599 | if (ret < 0) |
| 2600 | 2600 | return ret; |
| 2601 | 2601 | } |
| @@ -51,7 +51,7 @@ static int mp3_read_probe(AVProbeData *p) · 50 unmodified lines | ||
| 51 | 51 | |
| 52 | 52 | for(frames = 0; buf2 < end; frames++) { |
| 53 | 53 | header = AV_RB32(buf2); |
| 54 | − fsize = ff_mpa_decode_header(&avctx, header, &sample_rate, &sample_rate, &sample_rate, &sample_rate); | |
| 54 | + fsize = avpriv_mpa_decode_header(&avctx, header, &sample_rate, &sample_rate, &sample_rate, &sample_rate); | |
| 55 | 55 | if(fsize < 0) |
| 56 | 56 | break; |
| 57 | 57 | buf2 += fsize; |
| @@ -86,7 +86,7 @@ static int mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, int64_t base) · 28 unmodified lines | ||
| 86 | 86 | if(ff_mpa_check_header(v) < 0) |
| 87 | 87 | return -1; |
| 88 | 88 | |
| 89 | − if (ff_mpegaudio_decode_header(&c, v) == 0) | |
| 89 | + if (avpriv_mpegaudio_decode_header(&c, v) == 0) | |
| 90 | 90 | vbrtag_size = c.frame_size; |
| 91 | 91 | if(c.layer != 3) |
| 92 | 92 | return -1; |
| @@ -235,12 +235,12 @@ static int mp3_write_xing(AVFormatContext *s) · 234 unmodified lines | ||
| 235 | 235 | int srate_idx, i, channels; |
| 236 | 236 | int needed; |
| 237 | 237 | |
| 238 | − for (i = 0; i < FF_ARRAY_ELEMS(ff_mpa_freq_tab); i++) | |
| 239 | − if (ff_mpa_freq_tab[i] == codec->sample_rate) { | |
| 238 | + for (i = 0; i < FF_ARRAY_ELEMS(avpriv_mpa_freq_tab); i++) | |
| 239 | + if (avpriv_mpa_freq_tab[i] == codec->sample_rate) { | |
| 240 | 240 | srate_idx = i; |
| 241 | 241 | break; |
| 242 | 242 | } |
| 243 | − if (i == FF_ARRAY_ELEMS(ff_mpa_freq_tab)) { | |
| 243 | + if (i == FF_ARRAY_ELEMS(avpriv_mpa_freq_tab)) { | |
| 244 | 244 | av_log(s, AV_LOG_ERROR, "Unsupported sample rate.\n"); |
| 245 | 245 | return -1; |
| 246 | 246 | } |
| @@ -263,7 +263,7 @@ static int mp3_write_xing(AVFormatContext *s) · 16 unmodified lines | ||
| 263 | 263 | |
| 264 | 264 | mask = (bitrate_idx << 4) << 8; |
| 265 | 265 | header |= mask; |
| 266 | − ff_mpegaudio_decode_header(&c, header); | |
| 266 | + avpriv_mpegaudio_decode_header(&c, header); | |
| 267 | 267 | xing_offset=xing_offtbl[c.lsf == 1][c.nb_channels == 1]; |
| 268 | 268 | needed = 4 // header |
| 269 | 269 | + xing_offset |
| @@ -979,7 +979,7 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt) · 978 unmodified lines | ||
| 979 | 979 | } |
| 980 | 980 | |
| 981 | 981 | do { |
| 982 | − p = ff_find_start_code(p, buf_end, &state); | |
| 982 | + p = avpriv_mpv_find_start_code(p, buf_end, &state); | |
| 983 | 983 | //av_log(s, AV_LOG_INFO, "nal %d\n", state & 0x1f); |
| 984 | 984 | } while (p < buf_end && (state & 0x1f) != 9 && |
| 985 | 985 | (state & 0x1f) != 5 && (state & 0x1f) != 1); |
| @@ -416,7 +416,7 @@ static int decode_info_header(NUTContext *nut){ · 415 unmodified lines | ||
| 416 | 416 | |
| 417 | 417 | if(chapter_id && !stream_id_plus1){ |
| 418 | 418 | int64_t start= chapter_start / nut->time_base_count; |
| 419 | − chapter= ff_new_chapter(s, chapter_id, | |
| 419 | + chapter= avpriv_new_chapter(s, chapter_id, | |
| 420 | 420 | nut->time_base[chapter_start % nut->time_base_count], |
| 421 | 421 | start, start + chapter_len, NULL); |
| 422 | 422 | metadata = &chapter->metadata; |
| @@ -59,10 +59,10 @@ static int find_expected_header(AVCodecContext *c, int size, int key_frame, uint · 58 unmodified lines | ||
| 59 | 59 | else if(sample_rate < (44100 + 48000)/2) sample_rate_index=0; |
| 60 | 60 | else sample_rate_index=1; |
| 61 | 61 | |
| 62 | − sample_rate= ff_mpa_freq_tab[sample_rate_index] >> (lsf + mpeg25); | |
| 62 | + sample_rate= avpriv_mpa_freq_tab[sample_rate_index] >> (lsf + mpeg25); | |
| 63 | 63 | |
| 64 | 64 | for(bitrate_index=2; bitrate_index<30; bitrate_index++){ |
| 65 | − frame_size = ff_mpa_bitrate_tab[lsf][layer-1][bitrate_index>>1]; | |
| 65 | + frame_size = avpriv_mpa_bitrate_tab[lsf][layer-1][bitrate_index>>1]; | |
| 66 | 66 | frame_size = (frame_size * 144000) / (sample_rate << lsf) + (bitrate_index&1); |
| 67 | 67 | |
| 68 | 68 | if(frame_size == size) |
| @@ -274,7 +274,7 @@ static int ogg_build_flac_headers(AVCodecContext *avctx, · 273 unmodified lines | ||
| 274 | 274 | uint8_t *streaminfo; |
| 275 | 275 | uint8_t *p; |
| 276 | 276 | |
| 277 | − if (!ff_flac_is_extradata_valid(avctx, &format, &streaminfo)) | |
| 277 | + if (!avpriv_flac_is_extradata_valid(avctx, &format, &streaminfo)) | |
| 278 | 278 | return -1; |
| 279 | 279 | |
| 280 | 280 | // first packet: STREAMINFO |
| @@ -397,7 +397,7 @@ static int ogg_write_header(AVFormatContext *s) · 116 unmodified lines | ||
| 397 | 397 | int header_type = st->codec->codec_id == CODEC_ID_VORBIS ? 3 : 0x81; |
| 398 | 398 | int framing_bit = st->codec->codec_id == CODEC_ID_VORBIS ? 1 : 0; |
| 399 | 399 | |
| 400 | − if (ff_split_xiph_headers(st->codec->extradata, st->codec->extradata_size, | |
| 400 | + if (avpriv_split_xiph_headers(st->codec->extradata, st->codec->extradata_size, | |
| 401 | 401 | st->codec->codec_id == CODEC_ID_VORBIS ? 30 : 42, |
| 402 | 402 | oggstream->header, oggstream->header_len) < 0) { |
| 403 | 403 | av_log(s, AV_LOG_ERROR, "Extradata corrupted\n"); |
| @@ -36,7 +36,7 @@ static int dirac_header(AVFormatContext *s, int idx) · 35 unmodified lines | ||
| 36 | 36 | return 0; |
| 37 | 37 | |
| 38 | 38 | init_get_bits(&gb, os->buf + os->pstart + 13, (os->psize - 13) * 8); |
| 39 | − if (ff_dirac_parse_sequence_header(st->codec, &gb, &source) < 0) | |
| 39 | + if (avpriv_dirac_parse_sequence_header(st->codec, &gb, &source) < 0) | |
| 40 | 40 | return -1; |
| 41 | 41 | |
| 42 | 42 | st->codec->codec_type = AVMEDIA_TYPE_VIDEO; |
| @@ -55,7 +55,7 @@ flac_header (AVFormatContext * s, int idx) · 54 unmodified lines | ||
| 55 | 55 | if (get_bits_long(&gb, 32) != FLAC_STREAMINFO_SIZE) |
| 56 | 56 | return -1; |
| 57 | 57 | |
| 58 | − ff_flac_parse_streaminfo(st->codec, &si, streaminfo_start); | |
| 58 | + avpriv_flac_parse_streaminfo(st->codec, &si, streaminfo_start); | |
| 59 | 59 | |
| 60 | 60 | st->codec->codec_type = AVMEDIA_TYPE_AUDIO; |
| 61 | 61 | st->codec->codec_id = CODEC_ID_FLAC; |
| @@ -31,6 +31,7 @@ · 30 unmodified lines | ||
| 31 | 31 | #include "oggdec.h" |
| 32 | 32 | |
| 33 | 33 | struct speex_params { |
| 34 | + int packet_size; | |
| 34 | 35 | int final_packet_duration; |
| 35 | 36 | int seq; |
| 36 | 37 | }; |
| @@ -58,14 +59,10 @@ static int speex_header(AVFormatContext *s, int idx) { · 21 unmodified lines | ||
| 58 | 59 | st->codec->sample_rate = AV_RL32(p + 36); |
| 59 | 60 | st->codec->channels = AV_RL32(p + 48); |
| 60 | 61 | |
| 61 | − /* We treat the whole Speex packet as a single frame everywhere Speex | |
| 62 | − is handled in FFmpeg. This avoids the complexities of splitting | |
| 63 | − and joining individual Speex frames, which are not always | |
| 64 | − byte-aligned. */ | |
| 65 | − st->codec->frame_size = AV_RL32(p + 56); | |
| 66 | − frames_per_packet = AV_RL32(p + 64); | |
| 62 | + spxp->packet_size = AV_RL32(p + 56); | |
| 63 | + frames_per_packet = AV_RL32(p + 64); | |
| 67 | 64 | if (frames_per_packet) |
| 68 | − st->codec->frame_size *= frames_per_packet; | |
| 65 | + spxp->packet_size *= frames_per_packet; | |
| 69 | 66 | |
| 70 | 67 | st->codec->extradata_size = os->psize; |
| 71 | 68 | st->codec->extradata = av_malloc(st->codec->extradata_size |
| @@ -95,7 +92,7 @@ static int speex_packet(AVFormatContext *s, int idx) · 23 unmodified lines | ||
| 95 | 92 | struct ogg *ogg = s->priv_data; |
| 96 | 93 | struct ogg_stream *os = ogg->streams + idx; |
| 97 | 94 | struct speex_params *spxp = os->private; |
| 98 | − int packet_size = s->streams[idx]->codec->frame_size; | |
| 95 | + int packet_size = spxp->packet_size; | |
| 99 | 96 | |
| 100 | 97 | if (os->flags & OGG_FLAG_EOS && os->lastpts != AV_NOPTS_VALUE && |
| 101 | 98 | os->granule > 0) { |
| @@ -108,9 +105,10 @@ static int speex_packet(AVFormatContext *s, int idx) · 6 unmodified lines | ||
| 108 | 105 | |
| 109 | 106 | if (!os->lastpts && os->granule > 0) |
| 110 | 107 | /* first packet */ |
| 111 | − os->pduration = os->granule - packet_size * (ogg_page_packets(os) - 1); | |
| 112 | − else if (os->flags & OGG_FLAG_EOS && os->segp == os->nsegs && | |
| 113 | − spxp->final_packet_duration) | |
| 108 | + os->lastpts = os->lastdts = os->granule - packet_size * | |
| 109 | + ogg_page_packets(os); | |
| 110 | + if (os->flags & OGG_FLAG_EOS && os->segp == os->nsegs && | |
| 111 | + spxp->final_packet_duration) | |
| 114 | 112 | /* final packet */ |
| 115 | 113 | os->pduration = spxp->final_packet_duration; |
| 116 | 114 | else |
| @@ -45,7 +45,7 @@ static int ogm_chapter(AVFormatContext *as, uint8_t *key, uint8_t *val) · 44 unmodified lines | ||
| 45 | 45 | if (sscanf(val, "%02d:%02d:%02d.%03d", &h, &m, &s, &ms) < 4) |
| 46 | 46 | return 0; |
| 47 | 47 | |
| 48 | − ff_new_chapter(as, cnum, (AVRational){1,1000}, | |
| 48 | + avpriv_new_chapter(as, cnum, (AVRational){1,1000}, | |
| 49 | 49 | ms + 1000*(s + 60*(m + 60*h)), |
| 50 | 50 | AV_NOPTS_VALUE, NULL); |
| 51 | 51 | av_free(val); |
| @@ -56,7 +56,7 @@ void ff_rtp_send_mpegvideo(AVFormatContext *s1, const uint8_t *buf1, int size) · 55 unmodified lines | ||
| 56 | 56 | r1 = buf1; |
| 57 | 57 | while (1) { |
| 58 | 58 | start_code = -1; |
| 59 | − r = ff_find_start_code(r1, end, &start_code); | |
| 59 | + r = avpriv_mpv_find_start_code(r1, end, &start_code); | |
| 60 | 60 | if((start_code & 0xFFFFFF00) == 0x100) { |
| 61 | 61 | /* New start code found */ |
| 62 | 62 | if (start_code == 0x100) { |
| @@ -252,7 +252,7 @@ static char *xiph_extradata2config(AVCodecContext *c) · 251 unmodified lines | ||
| 252 | 252 | return NULL; |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | − if (ff_split_xiph_headers(c->extradata, c->extradata_size, | |
| 255 | + if (avpriv_split_xiph_headers(c->extradata, c->extradata_size, | |
| 256 | 256 | first_header_size, header_start, |
| 257 | 257 | header_len) < 0) { |
| 258 | 258 | av_log(c, AV_LOG_ERROR, "Extradata corrupt.\n"); |
| @@ -342,7 +342,7 @@ static char *latm_context2config(AVCodecContext *c) · 83 unmodified lines | ||
| 342 | 342 | char *config; |
| 343 | 343 | |
| 344 | 344 | for (rate_index = 0; rate_index < 16; rate_index++) |
| 345 | − if (ff_mpeg4audio_sample_rates[rate_index] == c->sample_rate) | |
| 345 | + if (avpriv_mpeg4audio_sample_rates[rate_index] == c->sample_rate) | |
| 346 | 346 | break; |
| 347 | 347 | if (rate_index == 16) { |
| 348 | 348 | av_log(c, AV_LOG_ERROR, "Unsupported sample rate\n"); |
| @@ -57,7 +57,7 @@ static int spdif_get_offset_and_codec(AVFormatContext *s, · 56 unmodified lines | ||
| 57 | 57 | break; |
| 58 | 58 | case IEC61937_MPEG2_AAC: |
| 59 | 59 | init_get_bits(&gbc, buf, AAC_ADTS_HEADER_SIZE * 8); |
| 60 | − if (ff_aac_parse_header(&gbc, &aac_hdr)) { | |
| 60 | + if (avpriv_aac_parse_header(&gbc, &aac_hdr)) { | |
| 61 | 61 | if (s) /* be silent during a probe */ |
| 62 | 62 | av_log(s, AV_LOG_ERROR, "Invalid AAC packet in IEC 61937\n"); |
| 63 | 63 | return AVERROR_INVALIDDATA; |
| @@ -349,7 +349,7 @@ static int spdif_header_aac(AVFormatContext *s, AVPacket *pkt) · 348 unmodified lines | ||
| 349 | 349 | int ret; |
| 350 | 350 | |
| 351 | 351 | init_get_bits(&gbc, pkt->data, AAC_ADTS_HEADER_SIZE * 8); |
| 352 | − ret = ff_aac_parse_header(&gbc, &hdr); | |
| 352 | + ret = avpriv_aac_parse_header(&gbc, &hdr); | |
| 353 | 353 | if (ret < 0) { |
| 354 | 354 | av_log(s, AV_LOG_ERROR, "Wrong AAC file format\n"); |
| 355 | 355 | return AVERROR_INVALIDDATA; |
| @@ -2143,7 +2143,6 @@ static int has_codec_parameters(AVCodecContext *avctx) · 2142 unmodified lines | ||
| 2143 | 2143 | avctx->codec_id == CODEC_ID_MP1 || |
| 2144 | 2144 | avctx->codec_id == CODEC_ID_MP2 || |
| 2145 | 2145 | avctx->codec_id == CODEC_ID_MP3 || |
| 2146 | − avctx->codec_id == CODEC_ID_SPEEX || | |
| 2147 | 2146 | avctx->codec_id == CODEC_ID_CELT)) |
| 2148 | 2147 | return 0; |
| 2149 | 2148 | break; |
| @@ -2224,7 +2223,7 @@ enum CodecID ff_codec_get_id(const AVCodecTag *tags, unsigned int tag) · 74 unmodified lines | ||
| 2224 | 2223 | return tags[i].id; |
| 2225 | 2224 | } |
| 2226 | 2225 | for(i=0; tags[i].id != CODEC_ID_NONE; i++) { |
| 2227 | − if (ff_toupper4(tag) == ff_toupper4(tags[i].tag)) | |
| 2226 | + if (avpriv_toupper4(tag) == avpriv_toupper4(tags[i].tag)) | |
| 2228 | 2227 | return tags[i].id; |
| 2229 | 2228 | } |
| 2230 | 2229 | return CODEC_ID_NONE; |
| @@ -2845,7 +2844,7 @@ AVProgram *av_new_program(AVFormatContext *ac, int id) · 614 unmodified lines | ||
| 2845 | 2844 | return program; |
| 2846 | 2845 | } |
| 2847 | 2846 | |
| 2848 | −AVChapter *ff_new_chapter(AVFormatContext *s, int id, AVRational time_base, int64_t start, int64_t end, const char *title) | |
| 2847 | +AVChapter *avpriv_new_chapter(AVFormatContext *s, int id, AVRational time_base, int64_t start, int64_t end, const char *title) | |
| 2849 | 2848 | { |
| 2850 | 2849 | AVChapter *chapter = NULL; |
| 2851 | 2850 | int i; |
| @@ -2969,7 +2968,7 @@ static int validate_codec_tag(AVFormatContext *s, AVStream *st) · 117 unmodified lines | ||
| 2969 | 2968 | for (n = 0; s->oformat->codec_tag[n]; n++) { |
| 2970 | 2969 | avctag = s->oformat->codec_tag[n]; |
| 2971 | 2970 | while (avctag->id != CODEC_ID_NONE) { |
| 2972 | − if (ff_toupper4(avctag->tag) == ff_toupper4(st->codec->codec_tag)) { | |
| 2971 | + if (avpriv_toupper4(avctag->tag) == avpriv_toupper4(st->codec->codec_tag)) { | |
| 2973 | 2972 | id = avctag->id; |
| 2974 | 2973 | if (id == st->codec->codec_id) |
| 2975 | 2974 | return 1; |
| @@ -1 +1 @@ | ||
| 1 | −9949141c405524f37ef1058b1ef4114b | |
| 1 | +da93c50961443b88fce416ae61c8ca8a | |