diff options
113 files changed, 860 insertions, 599 deletions
@@ -66,6 +66,7 @@ easier to use. The changes are: - libutvideo wrapper (--enable-libutvideo) - aevalsrc audio source added - Ut Video decoder +- Speex encoding via libspeex version 0.8: @@ -182,7 +182,7 @@ External library support: --enable-libopenjpeg enable JPEG 2000 decoding via OpenJPEG [no] --enable-librtmp enable RTMP[E] support via librtmp [no] --enable-libschroedinger enable Dirac support via libschroedinger [no] - --enable-libspeex enable Speex encoding and decoding via libspeex [no] + --enable-libspeex enable Speex support via libspeex [no] --enable-libstagefright-h264 enable H.264 decoding via libstagefright [no] --enable-libtheora enable Theora encoding via libtheora [no] --enable-libutvideo enable Ut Video decoding via libutvideo [no] diff --git a/libavcodec/Makefile b/libavcodec/Makefile index c369a3dc1e..147b37fa5f 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -702,6 +702,7 @@ SKIPHEADERS-$(CONFIG_LIBSCHROEDINGER) += libschroedinger.h SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_internal.h SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h SKIPHEADERS-$(CONFIG_XVMC) += xvmc.h +SKIPHEADERS-$(HAVE_W32THREADS) += w32pthreads.h TESTPROGS = cabac dct fft fft-fixed h264 iirfilter rangecoder snow TESTPROGS-$(HAVE_MMX) += motion diff --git a/libavcodec/aac_adtstoasc_bsf.c b/libavcodec/aac_adtstoasc_bsf.c index 2e14b1a0b6..3cb065ed5e 100644 --- a/libavcodec/aac_adtstoasc_bsf.c +++ b/libavcodec/aac_adtstoasc_bsf.c @@ -55,7 +55,7 @@ static int aac_adtstoasc_filter(AVBitStreamFilterContext *bsfc, if (show_bits(&gb, 12) != 0xfff) return 0; - if (ff_aac_parse_header(&gb, &hdr) < 0) { + if (avpriv_aac_parse_header(&gb, &hdr) < 0) { av_log(avctx, AV_LOG_ERROR, "Error parsing ADTS frame header!\n"); return -1; } @@ -78,7 +78,7 @@ static int aac_adtstoasc_filter(AVBitStreamFilterContext *bsfc, return -1; } init_put_bits(&pb, pce_data, MAX_PCE_SIZE); - pce_size = ff_copy_pce_data(&pb, &gb)/8; + pce_size = avpriv_copy_pce_data(&pb, &gb)/8; flush_put_bits(&pb); buf_size -= get_bits_count(&gb)/8; buf += get_bits_count(&gb)/8; diff --git a/libavcodec/aac_parser.c b/libavcodec/aac_parser.c index 9165178d15..3982ce6f91 100644 --- a/libavcodec/aac_parser.c +++ b/libavcodec/aac_parser.c @@ -40,7 +40,7 @@ static int aac_sync(uint64_t state, AACAC3ParseContext *hdr_info, tmp.u64 = av_be2ne64(state); init_get_bits(&bits, tmp.u8+8-AAC_ADTS_HEADER_SIZE, AAC_ADTS_HEADER_SIZE * 8); - if ((size = ff_aac_parse_header(&bits, &hdr)) < 0) + if ((size = avpriv_aac_parse_header(&bits, &hdr)) < 0) return 0; *need_next_header = 0; *new_frame_start = 1; diff --git a/libavcodec/aacadtsdec.c b/libavcodec/aacadtsdec.c index fd86d288a6..c9718c4599 100644 --- a/libavcodec/aacadtsdec.c +++ b/libavcodec/aacadtsdec.c @@ -26,7 +26,7 @@ #include "get_bits.h" #include "mpeg4audio.h" -int ff_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr) +int avpriv_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr) { int size, rdb, ch, sr; int aot, crc_abs; @@ -39,7 +39,7 @@ int ff_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr) crc_abs = get_bits1(gbc); /* protection_absent */ aot = get_bits(gbc, 2); /* profile_objecttype */ sr = get_bits(gbc, 4); /* sample_frequency_index */ - if(!ff_mpeg4audio_sample_rates[sr]) + if(!avpriv_mpeg4audio_sample_rates[sr]) return AAC_AC3_PARSE_ERROR_SAMPLE_RATE; skip_bits1(gbc); /* private_bit */ ch = get_bits(gbc, 3); /* channel_configuration */ @@ -62,7 +62,7 @@ int ff_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr) hdr->crc_absent = crc_abs; hdr->num_aac_frames = rdb + 1; hdr->sampling_index = sr; - hdr->sample_rate = ff_mpeg4audio_sample_rates[sr]; + hdr->sample_rate = avpriv_mpeg4audio_sample_rates[sr]; hdr->samples = (rdb + 1) * 1024; hdr->bit_rate = size * 8 * hdr->sample_rate / hdr->samples; diff --git a/libavcodec/aacadtsdec.h b/libavcodec/aacadtsdec.h index 6e0a869cc5..fb2cbd9b35 100644 --- a/libavcodec/aacadtsdec.h +++ b/libavcodec/aacadtsdec.h @@ -49,6 +49,6 @@ typedef struct { * -2 if the version element is invalid, -3 if the sample rate * element is invalid, or -4 if the bit rate element is invalid. */ -int ff_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr); +int avpriv_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr); #endif /* AVCODEC_AACADTSDEC_H */ diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index 6963d71a3f..97fddfc95c 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -472,7 +472,7 @@ static int decode_audio_specific_config(AACContext *ac, init_get_bits(&gb, data, data_size * 8); - if ((i = ff_mpeg4audio_get_config(m4ac, data, asclen/8)) < 0) + if ((i = avpriv_mpeg4audio_get_config(m4ac, data, asclen/8)) < 0) return -1; if (m4ac->sampling_index > 12) { 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) int size; AACADTSHeaderInfo hdr_info; - size = ff_aac_parse_header(gb, &hdr_info); + size = avpriv_aac_parse_header(gb, &hdr_info); if (size > 0) { if (hdr_info.chan_config) { enum ChannelPosition new_che_pos[4][MAX_ELEM_ID]; diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index 95523ca366..d0b24d8b96 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -180,7 +180,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) avctx->frame_size = 1024; for (i = 0; i < 16; i++) - if (avctx->sample_rate == ff_mpeg4audio_sample_rates[i]) + if (avctx->sample_rate == avpriv_mpeg4audio_sample_rates[i]) break; if (i == 16) { 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, put_bits(&s->pb, 8, namelen - 16); put_bits(&s->pb, 4, 0); //extension type - filler padbits = 8 - (put_bits_count(&s->pb) & 7); - align_put_bits(&s->pb); + avpriv_align_put_bits(&s->pb); for (i = 0; i < namelen - 2; i++) put_bits(&s->pb, 8, name[i]); put_bits(&s->pb, 12 - padbits, 0); diff --git a/libavcodec/ac3_parser.c b/libavcodec/ac3_parser.c index 43feb5bc38..3d2fdb5ecf 100644 --- a/libavcodec/ac3_parser.c +++ b/libavcodec/ac3_parser.c @@ -35,7 +35,7 @@ static const uint8_t eac3_blocks[4] = { }; -int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr) +int avpriv_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr) { int frame_size_code; @@ -141,7 +141,7 @@ static int ac3_sync(uint64_t state, AACAC3ParseContext *hdr_info, GetBitContext gbc; init_get_bits(&gbc, tmp.u8+8-AC3_HEADER_SIZE, 54); - err = ff_ac3_parse_header(&gbc, &hdr); + err = avpriv_ac3_parse_header(&gbc, &hdr); if(err < 0) return 0; diff --git a/libavcodec/ac3_parser.h b/libavcodec/ac3_parser.h index 50b70b08e5..b5022de2d8 100644 --- a/libavcodec/ac3_parser.h +++ b/libavcodec/ac3_parser.h @@ -36,6 +36,6 @@ * -2 if the bsid (version) element is invalid, -3 if the fscod (sample rate) * element is invalid, or -4 if the frmsizecod (bit rate) element is invalid. */ -int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr); +int avpriv_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr); #endif /* AVCODEC_AC3_PARSER_H */ diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index 120041f2d0..84a469193e 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -261,7 +261,7 @@ static int parse_frame_header(AC3DecodeContext *s) AC3HeaderInfo hdr; int err; - err = ff_ac3_parse_header(&s->gbc, &hdr); + err = avpriv_ac3_parse_header(&s->gbc, &hdr); if(err) return err; diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c index 9a79180d82..661f264cbf 100644 --- a/libavcodec/alsdec.c +++ b/libavcodec/alsdec.c @@ -289,7 +289,7 @@ static av_cold int read_specific_config(ALSDecContext *ctx) init_get_bits(&gb, avctx->extradata, avctx->extradata_size * 8); - config_offset = ff_mpeg4audio_get_config(&m4ac, avctx->extradata, + config_offset = avpriv_mpeg4audio_get_config(&m4ac, avctx->extradata, avctx->extradata_size); if (config_offset < 0) diff --git a/libavcodec/asv1.c b/libavcodec/asv1.c index a53d238fdd..ab5ac8d68e 100644 --- a/libavcodec/asv1.c +++ b/libavcodec/asv1.c @@ -497,7 +497,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, } emms_c(); - align_put_bits(&a->pb); + avpriv_align_put_bits(&a->pb); while(put_bits_count(&a->pb)&31) put_bits(&a->pb, 8, 0); diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 9a24da7b2a..c2b9096d87 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -210,8 +210,10 @@ enum CodecID { CODEC_ID_DFA, CODEC_ID_WMV3IMAGE, CODEC_ID_VC1IMAGE, +#if LIBAVCODEC_VERSION_MAJOR == 53 CODEC_ID_8SVX_RAW, CODEC_ID_G2M, +#endif CODEC_ID_UTVIDEO_DEPRECATED, CODEC_ID_UTVIDEO = 0x800, @@ -676,8 +678,10 @@ typedef struct RcOverride{ /* Codec can export data for HW decoding (XvMC). */ #define CODEC_CAP_HWACCEL 0x0010 /** - * Codec has a nonzero delay and needs to be fed with NULL at the end to get the delayed data. - * If this is not set, the codec is guaranteed to never be fed with NULL data. + * Codec has a nonzero delay and needs to be fed with avpkt->data=NULL, + * avpkt->size=0 at the end to get the delayed data until the decoder no longer + * returns frames. If this is not set, the codec is guaranteed to never be fed + * with NULL data. */ #define CODEC_CAP_DELAY 0x0020 /** @@ -3608,6 +3612,7 @@ enum PixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum PixelForma enum PixelFormat avcodec_find_best_pix_fmt2(enum PixelFormat dst_pix_fmt1, enum PixelFormat dst_pix_fmt2, enum PixelFormat src_pix_fmt, int has_alpha, int *loss_ptr); +#if FF_API_GET_ALPHA_INFO #define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */ #define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */ @@ -3615,8 +3620,10 @@ enum PixelFormat avcodec_find_best_pix_fmt2(enum PixelFormat dst_pix_fmt1, enum * Tell if an image really has transparent alpha values. * @return ored mask of FF_ALPHA_xxx constants */ +attribute_deprecated int img_get_alpha_info(const AVPicture *src, enum PixelFormat pix_fmt, int width, int height); +#endif /* deinterlace a picture */ /* deinterlace - if not supported return -1 */ @@ -3940,6 +3947,10 @@ int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options) * samples should be 16 byte aligned unless the CPU doesn't need it * (AltiVec and SSE do). * + * @note Codecs which have the CODEC_CAP_DELAY capability set have a delay + * between input and output, these need to be fed with avpkt->data=NULL, + * avpkt->size=0 at the end to return the remaining frames. + * * @param avctx the codec context * @param[out] samples the output buffer, sample type in avctx->sample_fmt * @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, * * In practice, avpkt->data should have 4 byte alignment at minimum. * - * @note Some codecs have a delay between input and output, these need to be - * fed with avpkt->data=NULL, avpkt->size=0 at the end to return the remaining frames. + * @note Codecs which have the CODEC_CAP_DELAY capability set have a delay + * between input and output, these need to be fed with avpkt->data=NULL, + * avpkt->size=0 at the end to return the remaining frames. * * @param avctx the codec context * @param[out] picture The AVFrame in which the decoded video frame will be stored. diff --git a/libavcodec/bitstream.c b/libavcodec/bitstream.c index 191190d8e2..d4d7623bc3 100644 --- a/libavcodec/bitstream.c +++ b/libavcodec/bitstream.c @@ -41,7 +41,7 @@ const uint8_t ff_log2_run[41]={ 24, }; -void align_put_bits(PutBitContext *s) +void avpriv_align_put_bits(PutBitContext *s) { put_bits(s,s->bit_left & 7,0); } @@ -56,7 +56,7 @@ void ff_put_string(PutBitContext *pb, const char *string, int terminate_string) put_bits(pb, 8, 0); } -void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length) +void avpriv_copy_bits(PutBitContext *pb, const uint8_t *src, int length) { int words= length>>4; int bits= length&15; diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c index fedee8bf72..2bf968ba22 100644 --- a/libavcodec/cavsdec.c +++ b/libavcodec/cavsdec.c @@ -625,8 +625,8 @@ static int decode_seq_header(AVSContext *h) { s->low_delay = get_bits1(&s->gb); h->mb_width = (s->width + 15) >> 4; h->mb_height = (s->height + 15) >> 4; - h->s.avctx->time_base.den = ff_frame_rate_tab[frame_rate_code].num; - h->s.avctx->time_base.num = ff_frame_rate_tab[frame_rate_code].den; + h->s.avctx->time_base.den = avpriv_frame_rate_tab[frame_rate_code].num; + h->s.avctx->time_base.num = avpriv_frame_rate_tab[frame_rate_code].den; h->s.avctx->width = s->width; h->s.avctx->height = s->height; if(!h->top_qp) @@ -664,7 +664,7 @@ static int cavs_decode_frame(AVCodecContext * avctx,void *data, int *data_size, buf_ptr = buf; buf_end = buf + buf_size; for(;;) { - buf_ptr = ff_find_start_code(buf_ptr,buf_end, &stc); + buf_ptr = avpriv_mpv_find_start_code(buf_ptr,buf_end, &stc); if((stc & 0xFFFFFE00) || buf_ptr == buf_end) return FFMAX(0, buf_ptr - buf - s->parse_context.last_index); input_size = (buf_end - buf_ptr)*8; diff --git a/libavcodec/cljr.c b/libavcodec/cljr.c index 8af149fa58..6e352b8e61 100644 --- a/libavcodec/cljr.c +++ b/libavcodec/cljr.c @@ -105,7 +105,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, emms_c(); - align_put_bits(&a->pb); + avpriv_align_put_bits(&a->pb); while(get_bit_count(&a->pb)&31) put_bits(&a->pb, 8, 0); diff --git a/libavcodec/dirac.c b/libavcodec/dirac.c index 1582a5f8f2..e637c4951f 100644 --- a/libavcodec/dirac.c +++ b/libavcodec/dirac.c @@ -145,7 +145,7 @@ static int parse_source_parameters(AVCodecContext *avctx, GetBitContext *gb, } if (source->frame_rate_index > 0) { if (source->frame_rate_index <= 8) - frame_rate = ff_frame_rate_tab[source->frame_rate_index]; + frame_rate = avpriv_frame_rate_tab[source->frame_rate_index]; else frame_rate = dirac_frame_rate[source->frame_rate_index-9]; } @@ -242,7 +242,7 @@ static int parse_source_parameters(AVCodecContext *avctx, GetBitContext *gb, return 0; } -int ff_dirac_parse_sequence_header(AVCodecContext *avctx, GetBitContext *gb, +int avpriv_dirac_parse_sequence_header(AVCodecContext *avctx, GetBitContext *gb, dirac_source_params *source) { unsigned version_major; diff --git a/libavcodec/dirac.h b/libavcodec/dirac.h index 87d66ccab6..6d41be740a 100644 --- a/libavcodec/dirac.h +++ b/libavcodec/dirac.h @@ -51,7 +51,7 @@ typedef struct { uint8_t color_spec_index; ///< index into dirac_color_spec_presets[] } dirac_source_params; -int ff_dirac_parse_sequence_header(AVCodecContext *avctx, GetBitContext *gb, - dirac_source_params *source); +int avpriv_dirac_parse_sequence_header(AVCodecContext *avctx, GetBitContext *gb, + dirac_source_params *source); #endif /* AVCODEC_DIRAC_H */ diff --git a/libavcodec/dv.c b/libavcodec/dv.c index c3cdf9ea98..462cbbed45 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -349,7 +349,7 @@ static av_cold int dvvideo_init(AVCodecContext *avctx) static av_cold int dvvideo_init_encoder(AVCodecContext *avctx) { - if (!ff_dv_codec_profile(avctx)) { + if (!avpriv_dv_codec_profile(avctx)) { av_log(avctx, AV_LOG_ERROR, "Found no DV profile for %ix%i %s video\n", avctx->width, avctx->height, av_get_pix_fmt_name(avctx->pix_fmt)); return -1; @@ -1072,7 +1072,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, const uint8_t* vsc_pack; int apt, is16_9; - s->sys = ff_dv_frame_profile2(avctx, s->sys, buf, buf_size); + s->sys = avpriv_dv_frame_profile2(avctx, s->sys, buf, buf_size); if (!s->sys || buf_size < s->sys->frame_size || dv_init_dynamic_tables(s->sys)) { av_log(avctx, AV_LOG_ERROR, "could not find dv frame profile\n"); 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, { DVVideoContext *s = c->priv_data; - s->sys = ff_dv_codec_profile(c); + s->sys = avpriv_dv_codec_profile(c); if (!s->sys || buf_size < s->sys->frame_size || dv_init_dynamic_tables(s->sys)) return -1; diff --git a/libavcodec/dvdata.c b/libavcodec/dvdata.c index 66265bc331..b29f5ce53f 100644 --- a/libavcodec/dvdata.c +++ b/libavcodec/dvdata.c @@ -246,7 +246,7 @@ static const DVprofile dv_profiles[] = { } }; -const DVprofile* ff_dv_frame_profile2(AVCodecContext* codec, const DVprofile *sys, +const DVprofile* avpriv_dv_frame_profile2(AVCodecContext* codec, const DVprofile *sys, const uint8_t* frame, unsigned buf_size) { int i, dsf, stype; @@ -276,13 +276,13 @@ const DVprofile* ff_dv_frame_profile2(AVCodecContext* codec, const DVprofile *sy return NULL; } -const DVprofile* ff_dv_frame_profile(const DVprofile *sys, +const DVprofile* avpriv_dv_frame_profile(const DVprofile *sys, const uint8_t* frame, unsigned buf_size) { - return ff_dv_frame_profile2(NULL, sys, frame, buf_size); + return avpriv_dv_frame_profile2(NULL, sys, frame, buf_size); } -const DVprofile* ff_dv_codec_profile(AVCodecContext* codec) +const DVprofile* avpriv_dv_codec_profile(AVCodecContext* codec) { int i; diff --git a/libavcodec/dvdata.h b/libavcodec/dvdata.h index 33a5cf1af6..557e744b8e 100644 --- a/libavcodec/dvdata.h +++ b/libavcodec/dvdata.h @@ -274,11 +274,11 @@ enum dv_pack_type { */ #define DV_MAX_BPM 8 -const DVprofile* ff_dv_frame_profile(const DVprofile *sys, +const DVprofile* avpriv_dv_frame_profile(const DVprofile *sys, const uint8_t* frame, unsigned buf_size); -const DVprofile* ff_dv_frame_profile2(AVCodecContext* codec, const DVprofile *sys, +const DVprofile* avpriv_dv_frame_profile2(AVCodecContext* codec, const DVprofile *sys, const uint8_t* frame, unsigned buf_size); -const DVprofile* ff_dv_codec_profile(AVCodecContext* codec); +const DVprofile* avpriv_dv_codec_profile(AVCodecContext* codec); static inline int dv_write_dif_id(enum dv_section_type t, uint8_t chan_num, uint8_t seq_num, uint8_t dif_num, diff --git a/libavcodec/flac.h b/libavcodec/flac.h index fcd80996dc..65965af6ad 100644 --- a/libavcodec/flac.h +++ b/libavcodec/flac.h @@ -95,8 +95,8 @@ typedef struct FLACFrameInfo { * @param[out] s where parsed information is stored * @param[in] buffer pointer to start of 34-byte streaminfo data */ -void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, - const uint8_t *buffer); +void avpriv_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, + const uint8_t *buffer); /** * Validate the FLAC extradata. @@ -105,9 +105,9 @@ void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, * @param[out] streaminfo_start pointer to start of 34-byte STREAMINFO data. * @return 1 if valid, 0 if not valid. */ -int ff_flac_is_extradata_valid(AVCodecContext *avctx, - enum FLACExtradataFormat *format, - uint8_t **streaminfo_start); +int avpriv_flac_is_extradata_valid(AVCodecContext *avctx, + enum FLACExtradataFormat *format, + uint8_t **streaminfo_start); /** * Parse the metadata block parameters from the header. @@ -116,8 +116,8 @@ int ff_flac_is_extradata_valid(AVCodecContext *avctx, * @param[out] type metadata block type * @param[out] size metadata block size */ -void ff_flac_parse_block_header(const uint8_t *block_header, - int *last, int *type, int *size); +void avpriv_flac_parse_block_header(const uint8_t *block_header, + int *last, int *type, int *size); /** * Calculate an estimate for the maximum frame size based on verbatim mode. diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c index afc89203a3..cebe3e3e62 100644 --- a/libavcodec/flacdec.c +++ b/libavcodec/flacdec.c @@ -63,7 +63,7 @@ typedef struct FLACContext { static void allocate_buffers(FLACContext *s); -int ff_flac_is_extradata_valid(AVCodecContext *avctx, +int avpriv_flac_is_extradata_valid(AVCodecContext *avctx, enum FLACExtradataFormat *format, uint8_t **streaminfo_start) { @@ -104,11 +104,11 @@ static av_cold int flac_decode_init(AVCodecContext *avctx) if (!avctx->extradata) return 0; - if (!ff_flac_is_extradata_valid(avctx, &format, &streaminfo)) + if (!avpriv_flac_is_extradata_valid(avctx, &format, &streaminfo)) return -1; /* initialize based on the demuxer-supplied streamdata header */ - ff_flac_parse_streaminfo(avctx, (FLACStreaminfo *)s, streaminfo); + avpriv_flac_parse_streaminfo(avctx, (FLACStreaminfo *)s, streaminfo); if (s->bps > 16) avctx->sample_fmt = AV_SAMPLE_FMT_S32; else @@ -140,7 +140,7 @@ static void allocate_buffers(FLACContext *s) } } -void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, +void avpriv_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, const uint8_t *buffer) { GetBitContext gb; @@ -174,7 +174,7 @@ void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, dump_headers(avctx, s); } -void ff_flac_parse_block_header(const uint8_t *block_header, +void avpriv_flac_parse_block_header(const uint8_t *block_header, int *last, int *type, int *size) { int tmp = bytestream_get_byte(&block_header); @@ -201,12 +201,12 @@ static int parse_streaminfo(FLACContext *s, const uint8_t *buf, int buf_size) /* need more data */ return 0; } - ff_flac_parse_block_header(&buf[4], NULL, &metadata_type, &metadata_size); + avpriv_flac_parse_block_header(&buf[4], NULL, &metadata_type, &metadata_size); if (metadata_type != FLAC_METADATA_TYPE_STREAMINFO || metadata_size != FLAC_STREAMINFO_SIZE) { return AVERROR_INVALIDDATA; } - ff_flac_parse_streaminfo(s->avctx, (FLACStreaminfo *)s, &buf[8]); + avpriv_flac_parse_streaminfo(s->avctx, (FLACStreaminfo *)s, &buf[8]); allocate_buffers(s); s->got_streaminfo = 1; @@ -228,7 +228,7 @@ static int get_metadata_size(const uint8_t *buf, int buf_size) do { if (buf_end - buf < 4) return 0; - ff_flac_parse_block_header(buf, &metadata_last, NULL, &metadata_size); + avpriv_flac_parse_block_header(buf, &metadata_last, NULL, &metadata_size); buf += 4; if (buf_end - buf < metadata_size) { /* need more data in order to read the complete header */ diff --git a/libavcodec/flvenc.c b/libavcodec/flvenc.c index 99caa18d2d..ee373d0975 100644 --- a/libavcodec/flvenc.c +++ b/libavcodec/flvenc.c @@ -25,7 +25,7 @@ void ff_flv_encode_picture_header(MpegEncContext * s, int picture_number) { int format; - align_put_bits(&s->pb); + avpriv_align_put_bits(&s->pb); put_bits(&s->pb, 17, 1); put_bits(&s->pb, 5, (s->h263_flv-1)); /* 0: h263 escape codes 1: 11-bit escape codes */ diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c index 91d90d8989..a275bfda4a 100644 --- a/libavcodec/h261enc.c +++ b/libavcodec/h261enc.c @@ -53,7 +53,7 @@ void ff_h261_encode_picture_header(MpegEncContext * s, int picture_number){ H261Context * h = (H261Context *) s; int format, temp_ref; - align_put_bits(&s->pb); + avpriv_align_put_bits(&s->pb); /* Update the pointer to last GOB */ s->ptr_lastgob = put_bits_ptr(&s->pb); diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c index 962d351325..614dad35eb 100644 --- a/libavcodec/h264_parser.c +++ b/libavcodec/h264_parser.c @@ -153,7 +153,7 @@ static inline int parse_nal_units(AVCodecParserContext *s, for(;;) { int src_length, dst_length, consumed; - buf = ff_find_start_code(buf, buf_end, &state); + buf = avpriv_mpv_find_start_code(buf, buf_end, &state); if(buf >= buf_end) break; --buf; diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c index 64b0838857..2279875db2 100644 --- a/libavcodec/imgconvert.c +++ b/libavcodec/imgconvert.c @@ -747,6 +747,7 @@ int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, return 0; } +#if FF_API_GET_ALPHA_INFO /* NOTE: we scan all the pixels to have an exact information */ static int get_alpha_info_pal8(const AVPicture *src, int width, int height) { @@ -793,6 +794,7 @@ int img_get_alpha_info(const AVPicture *src, } return ret; } +#endif #if !(HAVE_MMX && HAVE_YASM) /* filter parameters: [-1 4 2 4 -1] // 8 */ diff --git a/libavcodec/internal.h b/libavcodec/internal.h index 68f49b5f1e..d431a85bf9 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -53,7 +53,7 @@ AVHWAccel *ff_find_hwaccel(enum CodecID codec_id, enum PixelFormat pix_fmt); */ int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b); -unsigned int ff_toupper4(unsigned int x); +unsigned int avpriv_toupper4(unsigned int x); /** * does needed setup of pkt_pts/pos and such for (re)get_buffer(); diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c index 3f4485f376..01c603e26d 100644 --- a/libavcodec/ituh263enc.c +++ b/libavcodec/ituh263enc.c @@ -126,7 +126,7 @@ void h263_encode_picture_header(MpegEncContext * s, int picture_number) coded_frame_rate= 1800000; coded_frame_rate_base= (1000+best_clock_code)*best_divisor; - align_put_bits(&s->pb); + avpriv_align_put_bits(&s->pb); /* Update the pointer to last GOB */ s->ptr_lastgob = put_bits_ptr(&s->pb); diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c index 06f365a223..d72287b296 100644 --- a/libavcodec/jpeglsenc.c +++ b/libavcodec/jpeglsenc.c @@ -357,7 +357,7 @@ static int encode_picture_ls(AVCodecContext *avctx, unsigned char *buf, int buf_ put_bits(&pb, 8, v); } } - align_put_bits(&pb); + avpriv_align_put_bits(&pb); av_free(buf2); /* End of image */ diff --git a/libavcodec/libavcodec.v b/libavcodec/libavcodec.v index 65699038ab..a9e7674e13 100644 --- a/libavcodec/libavcodec.v +++ b/libavcodec/libavcodec.v @@ -1,9 +1,8 @@ LIBAVCODEC_$MAJOR { - global: *; - local: - ff_*_bsf; - ff_*_decoder; - ff_*_encoder; - ff_*_hwaccel; - ff_*_parser; + global: av*; + audio_resample; + audio_resample_close; + #deprecated, remove after next bump + img_get_alpha_info; + local: *; }; diff --git a/libavcodec/libspeexenc.c b/libavcodec/libspeexenc.c index 79a9fb0760..a3176d1388 100644 --- a/libavcodec/libspeexenc.c +++ b/libavcodec/libspeexenc.c @@ -1,5 +1,7 @@ /* - * Copyright (c) 2009 by Xuggle Incorporated. All rights reserved. + * Copyright (C) 2009 Justin Ruggles + * Copyright (c) 2009 Xuggle Incorporated + * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or @@ -16,163 +18,307 @@ * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include <libavcodec/avcodec.h> + +/** + * @file + * libspeex Speex audio encoder + * + * Usage Guide + * This explains the values that need to be set prior to initialization in + * order to control various encoding parameters. + * + * Channels + * Speex only supports mono or stereo, so avctx->channels must be set to + * 1 or 2. + * + * Sample Rate / Encoding Mode + * Speex has 3 modes, each of which uses a specific sample rate. + * narrowband : 8 kHz + * wideband : 16 kHz + * ultra-wideband : 32 kHz + * avctx->sample_rate must be set to one of these 3 values. This will be + * used to set the encoding mode. + * + * Rate Control + * VBR mode is turned on by setting CODEC_FLAG_QSCALE in avctx->flags. + * avctx->global_quality is used to set the encoding quality. + * For CBR mode, avctx->bit_rate can be used to set the constant bitrate. + * Alternatively, the 'cbr_quality' option can be set from 0 to 10 to set + * a constant bitrate based on quality. + * For ABR mode, set avctx->bit_rate and set the 'abr' option to 1. + * Approx. Bitrate Range: + * narrowband : 2400 - 25600 bps + * wideband : 4000 - 43200 bps + * ultra-wideband : 4400 - 45200 bps + * + * Complexity + * Encoding complexity is controlled by setting avctx->compression_level. + * The valid range is 0 to 10. A higher setting gives generally better + * quality at the expense of encoding speed. This does not affect the + * bit rate. + * + * Frames-per-Packet + * The encoder defaults to using 1 frame-per-packet. However, it is + * sometimes desirable to use multiple frames-per-packet to reduce the + * amount of container overhead. This can be done by setting the + * 'frames_per_packet' option to a value 1 to 8. + */ + #include <speex/speex.h> #include <speex/speex_header.h> #include <speex/speex_stereo.h> +#include "libavutil/mathematics.h" +#include "libavutil/opt.h" +#include "avcodec.h" +#include "internal.h" typedef struct { - SpeexBits bits; - void *enc_state; - SpeexHeader header; + AVClass *class; ///< AVClass for private options + SpeexBits bits; ///< libspeex bitwriter context + SpeexHeader header; ///< libspeex header struct + void *enc_state; ///< libspeex encoder state + int frames_per_packet; ///< number of frames to encode in each packet + float vbr_quality; ///< VBR quality 0.0 to 10.0 + int cbr_quality; ///< CBR quality 0 to 10 + int abr; ///< flag to enable ABR + int pkt_frame_count; ///< frame count for the current packet + int lookahead; ///< encoder delay + int sample_count; ///< total sample count (used for pts) } LibSpeexEncContext; +static av_cold void print_enc_params(AVCodecContext *avctx, + LibSpeexEncContext *s) +{ + const char *mode_str = "unknown"; + + av_log(avctx, AV_LOG_DEBUG, "channels: %d\n", avctx->channels); + switch (s->header.mode) { + case SPEEX_MODEID_NB: mode_str = "narrowband"; break; + case SPEEX_MODEID_WB: mode_str = "wideband"; break; + case SPEEX_MODEID_UWB: mode_str = "ultra-wideband"; break; + } + av_log(avctx, AV_LOG_DEBUG, "mode: %s\n", mode_str); + if (s->header.vbr) { + av_log(avctx, AV_LOG_DEBUG, "rate control: VBR\n"); + av_log(avctx, AV_LOG_DEBUG, " quality: %f\n", s->vbr_quality); + } else if (s->abr) { + av_log(avctx, AV_LOG_DEBUG, "rate control: ABR\n"); + av_log(avctx, AV_LOG_DEBUG, " bitrate: %d bps\n", avctx->bit_rate); + } else { + av_log(avctx, AV_LOG_DEBUG, "rate control: CBR\n"); + av_log(avctx, AV_LOG_DEBUG, " bitrate: %d bps\n", avctx->bit_rate); + } + av_log(avctx, AV_LOG_DEBUG, "complexity: %d\n", + avctx->compression_level); + av_log(avctx, AV_LOG_DEBUG, "frame size: %d samples\n", + avctx->frame_size); + av_log(avctx, AV_LOG_DEBUG, "frames per packet: %d\n", + s->frames_per_packet); + av_log(avctx, AV_LOG_DEBUG, "packet size: %d\n", + avctx->frame_size * s->frames_per_packet); +} -static av_cold int libspeex_encode_init(AVCodecContext *avctx) +static av_cold int encode_init(AVCodecContext *avctx) { - LibSpeexEncContext *s = (LibSpeexEncContext*)avctx->priv_data; + LibSpeexEncContext *s = avctx->priv_data; const SpeexMode *mode; + uint8_t *header_data; + int header_size; + int32_t complexity; - if ((avctx->sample_fmt != SAMPLE_FMT_S16 && avctx->sample_fmt != SAMPLE_FMT_FLT) || - avctx->sample_rate <= 0 || - avctx->channels <= 0 || - avctx->channels > 2) - { - av_log(avctx, AV_LOG_ERROR, "Unsupported sample format, rate, or channels for speex"); - return -1; + /* channels */ + if (avctx->channels < 1 || avctx->channels > 2) { + av_log(avctx, AV_LOG_ERROR, "Invalid channels (%d). Only stereo and " + "mono are supported\n", avctx->channels); + return AVERROR(EINVAL); } - if (avctx->sample_rate <= 8000) - mode = &speex_nb_mode; - else if (avctx->sample_rate <= 16000) - mode = &speex_wb_mode; - else - mode = &speex_uwb_mode; + /* sample rate and encoding mode */ + switch (avctx->sample_rate) { + case 8000: mode = &speex_nb_mode; break; + case 16000: mode = &speex_wb_mode; break; + case 32000: mode = &speex_uwb_mode; break; + default: + av_log(avctx, AV_LOG_ERROR, "Sample rate of %d Hz is not supported. " + "Resample to 8, 16, or 32 kHz.\n", avctx->sample_rate); + return AVERROR(EINVAL); + } - speex_bits_init(&s->bits); + /* initialize libspeex */ s->enc_state = speex_encoder_init(mode); - if (!s->enc_state) - { - av_log(avctx, AV_LOG_ERROR, "could not initialize speex encoder"); + if (!s->enc_state) { + av_log(avctx, AV_LOG_ERROR, "Error initializing libspeex\n"); return -1; } + speex_init_header(&s->header, avctx->sample_rate, avctx->channels, mode); - // initialize the header - speex_init_header(&s->header, avctx->sample_rate, - avctx->channels, mode); - - // TODO: It'd be nice to support VBR here, but - // I'm uncertain what AVCodecContext options to use - // to signal whether to turn it on. + /* rate control method and parameters */ if (avctx->flags & CODEC_FLAG_QSCALE) { - spx_int32_t quality = 0; - // Map global_quality's mpeg 1/2/4 scale into Speex's 0-10 scale - if (avctx->global_quality > FF_LAMBDA_MAX) - quality = 0; // lowest possible quality - else - quality = (spx_int32_t)((FF_LAMBDA_MAX-avctx->global_quality)*10.0/FF_LAMBDA_MAX); - speex_encoder_ctl(s->enc_state, SPEEX_SET_QUALITY, &quality); + /* VBR */ + s->header.vbr = 1; + speex_encoder_ctl(s->enc_state, SPEEX_SET_VBR, &s->header.vbr); + s->vbr_quality = av_clipf(avctx->global_quality / (float)FF_QP2LAMBDA, + 0.0f, 10.0f); + speex_encoder_ctl(s->enc_state, SPEEX_SET_VBR_QUALITY, &s->vbr_quality); } else { - // default to CBR - if (avctx->bit_rate > 0) - speex_encoder_ctl(s->enc_state, SPEEX_SET_BITRATE, &avctx->bit_rate); - // otherwise just take the default quality setting + s->header.bitrate = avctx->bit_rate; + if (avctx->bit_rate > 0) { + /* CBR or ABR by bitrate */ + if (s->abr) { + speex_encoder_ctl(s->enc_state, SPEEX_SET_ABR, + &s->header.bitrate); + speex_encoder_ctl(s->enc_state, SPEEX_GET_ABR, + &s->header.bitrate); + } else { + speex_encoder_ctl(s->enc_state, SPEEX_SET_BITRATE, + &s->header.bitrate); + speex_encoder_ctl(s->enc_state, SPEEX_GET_BITRATE, + &s->header.bitrate); + } + } else { + /* CBR by quality */ + speex_encoder_ctl(s->enc_state, SPEEX_SET_QUALITY, + &s->cbr_quality); + speex_encoder_ctl(s->enc_state, SPEEX_GET_BITRATE, + &s->header.bitrate); + } + /* stereo side information adds about 800 bps to the base bitrate */ + /* TODO: this should be calculated exactly */ + avctx->bit_rate = s->header.bitrate + (avctx->channels == 2 ? 800 : 0); } - // reset the bit-rate to the actual bit rate speex will use - speex_encoder_ctl(s->enc_state, SPEEX_GET_BITRATE, &s->header.bitrate); - avctx->bit_rate = s->header.bitrate; - - // get the actual sample rate - speex_encoder_ctl(s->enc_state, SPEEX_GET_SAMPLING_RATE, &s->header.rate); - avctx->sample_rate = s->header.rate; - - // get the frame-size. To align with FLV, we're going to put 2 frames - // per packet. If someone can tell me how to make this configurable - // from the avcodec contents, I'll mod this so it's not hard-coded. - // but without this, FLV files with speex data won't play correctly - // in flash player 10. - speex_encoder_ctl(s->enc_state, SPEEX_GET_FRAME_SIZE, &s->header.frame_size); - s->header.frames_per_packet = 2; // Need for FLV container support - avctx->frame_size = s->header.frame_size*s->header.frames_per_packet; - - // and we'll put a speex header packet into extradata so that muxers - // can use it. - avctx->extradata = speex_header_to_packet(&s->header, &avctx->extradata_size); + + /* set encoding complexity */ + if (avctx->compression_level > FF_COMPRESSION_DEFAULT) { + complexity = av_clip(avctx->compression_level, 0, 10); + speex_encoder_ctl(s->enc_state, SPEEX_SET_COMPLEXITY, &complexity); + } + speex_encoder_ctl(s->enc_state, SPEEX_GET_COMPLEXITY, &complexity); + avctx->compression_level = complexity; + + /* set packet size */ + avctx->frame_size = s->header.frame_size; + s->header.frames_per_packet = s->frames_per_packet; + + /* set encoding delay */ + speex_encoder_ctl(s->enc_state, SPEEX_GET_LOOKAHEAD, &s->lookahead); + s->sample_count = -s->lookahead; + + /* create header packet bytes from header struct */ + /* note: libspeex allocates the memory for header_data, which is freed + below with speex_header_free() */ + header_data = speex_header_to_packet(&s->header, &header_size); + + /* allocate extradata and coded_frame */ + avctx->extradata = av_malloc(header_size + FF_INPUT_BUFFER_PADDING_SIZE); + avctx->coded_frame = avcodec_alloc_frame(); + if (!avctx->extradata || !avctx->coded_frame) { + speex_header_free(header_data); + speex_encoder_destroy(s->enc_state); + av_log(avctx, AV_LOG_ERROR, "memory allocation error\n"); + return AVERROR(ENOMEM); + } + + /* copy header packet to extradata */ + memcpy(avctx->extradata, header_data, header_size); + avctx->extradata_size = header_size; + speex_header_free(header_data); + + /* init libspeex bitwriter */ + speex_bits_init(&s->bits); + + print_enc_params(avctx, s); return 0; } -static av_cold int libspeex_encode_frame( - AVCodecContext *avctx, uint8_t *frame, - int buf_size, void *data) +static int encode_frame(AVCodecContext *avctx, uint8_t *frame, int buf_size, + void *data) { - LibSpeexEncContext *s = (LibSpeexEncContext*)avctx->priv_data; - int i = 0; - - if (!data) - // nothing to flush - return 0; - - speex_bits_reset(&s->bits); - for(i = 0; i < s->header.frames_per_packet; i++) - { - if (avctx->sample_fmt == SAMPLE_FMT_FLT) - { - if (avctx->channels == 2) { - speex_encode_stereo( - (float*)data+i*s->header.frame_size, - s->header.frame_size, - &s->bits); - } - speex_encode(s->enc_state, - (float*)data+i*s->header.frame_size, &s->bits); - } else { - if (avctx->channels == 2) { - speex_encode_stereo_int( - (spx_int16_t*)data+i*s->header.frame_size, - s->header.frame_size, - &s->bits); - } - speex_encode_int(s->enc_state, - (spx_int16_t*)data+i*s->header.frame_size, &s->bits); + LibSpeexEncContext *s = avctx->priv_data; + int16_t *samples = data; + int sample_count = s->sample_count; + + if (data) { + /* encode Speex frame */ + if (avctx->channels == 2) + speex_encode_stereo_int(samples, s->header.frame_size, &s->bits); + speex_encode_int(s->enc_state, samples, &s->bits); + s->pkt_frame_count++; + s->sample_count += avctx->frame_size; + } else { + /* handle end-of-stream */ + if (!s->pkt_frame_count) + return 0; + /* add extra terminator codes for unused frames in last packet */ + while (s->pkt_frame_count < s->frames_per_packet) { + speex_bits_pack(&s->bits, 15, 5); + s->pkt_frame_count++; } } - // put in a terminator so this will fit in a OGG or FLV packet - speex_bits_insert_terminator(&s->bits); - if (buf_size >= speex_bits_nbytes(&s->bits)) { - return speex_bits_write(&s->bits, frame, buf_size); - } else { - av_log(avctx, AV_LOG_ERROR, "output buffer too small"); - return -1; + /* write output if all frames for the packet have been encoded */ + if (s->pkt_frame_count == s->frames_per_packet) { + s->pkt_frame_count = 0; + avctx->coded_frame->pts = + av_rescale_q(sample_count, (AVRational){ 1, avctx->sample_rate }, + avctx->time_base); + if (buf_size > speex_bits_nbytes(&s->bits)) { + int ret = speex_bits_write(&s->bits, frame, buf_size); + speex_bits_reset(&s->bits); + return ret; + } else { + av_log(avctx, AV_LOG_ERROR, "output buffer too small"); + return AVERROR(EINVAL); + } } + return 0; } -static av_cold int libspeex_encode_close(AVCodecContext *avctx) +static av_cold int encode_close(AVCodecContext *avctx) { - LibSpeexEncContext *s = (LibSpeexEncContext*)avctx->priv_data; + LibSpeexEncContext *s = avctx->priv_data; speex_bits_destroy(&s->bits); speex_encoder_destroy(s->enc_state); - s->enc_state = 0; - if (avctx->extradata) - speex_header_free(avctx->extradata); - avctx->extradata = 0; - avctx->extradata_size = 0; + + av_freep(&avctx->coded_frame); + av_freep(&avctx->extradata); return 0; } +#define OFFSET(x) offsetof(LibSpeexEncContext, x) +#define AE AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM +static const AVOption options[] = { + { "abr", "Use average bit rate", OFFSET(abr), AV_OPT_TYPE_INT, { 0 }, 0, 1, AE }, + { "cbr_quality", "Set quality value (0 to 10) for CBR", OFFSET(cbr_quality), AV_OPT_TYPE_INT, { 8 }, 0, 10, AE }, + { "frames_per_packet", "Number of frames to encode in each packet", OFFSET(frames_per_packet), AV_OPT_TYPE_INT, { 1 }, 1, 8, AE }, + { NULL }, +}; + +static const AVClass class = { + .class_name = "libspeex", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + +static const AVCodecDefault defaults[] = { + { "b", "0" }, + { "compression_level", "3" }, + { NULL }, +}; + AVCodec ff_libspeex_encoder = { - "libspeex", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_SPEEX, - sizeof(LibSpeexEncContext), - libspeex_encode_init, - libspeex_encode_frame, - libspeex_encode_close, - 0, - .capabilities = CODEC_CAP_DELAY, - .supported_samplerates = (const int[]){8000, 16000, 32000, 0}, - .sample_fmts = (enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_FLT,SAMPLE_FMT_NONE}, - .long_name = NULL_IF_CONFIG_SMALL("libspeex Speex Encoder"), + .name = "libspeex", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_SPEEX, + .priv_data_size = sizeof(LibSpeexEncContext), + .init = encode_init, + .encode = encode_frame, + .close = encode_close, + .capabilities = CODEC_CAP_DELAY, + .sample_fmts = (const enum SampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, + .long_name = NULL_IF_CONFIG_SMALL("libspeex Speex"), + .priv_class = &class, + .defaults = defaults, }; diff --git a/libavcodec/libvo-aacenc.c b/libavcodec/libvo-aacenc.c index c99b53f225..dcec664347 100644 --- a/libavcodec/libvo-aacenc.c +++ b/libavcodec/libvo-aacenc.c @@ -63,7 +63,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) } for (index = 0; index < 16; index++) - if (avctx->sample_rate == ff_mpeg4audio_sample_rates[index]) + if (avctx->sample_rate == avpriv_mpeg4audio_sample_rates[index]) break; if (index == 16) { av_log(avctx, AV_LOG_ERROR, "Unsupported sample rate %d\n", diff --git a/libavcodec/mp3_header_decompress_bsf.c b/libavcodec/mp3_header_decompress_bsf.c index a9c23b17ce..c08aa1fa05 100644 --- a/libavcodec/mp3_header_decompress_bsf.c +++ b/libavcodec/mp3_header_decompress_bsf.c @@ -50,10 +50,10 @@ static int mp3_header_decompress(AVBitStreamFilterContext *bsfc, AVCodecContext lsf = sample_rate < (24000+32000)/2; mpeg25 = sample_rate < (12000+16000)/2; sample_rate_index= (header>>10)&3; - sample_rate= ff_mpa_freq_tab[sample_rate_index] >> (lsf + mpeg25); //in case sample rate is a little off + sample_rate= avpriv_mpa_freq_tab[sample_rate_index] >> (lsf + mpeg25); //in case sample rate is a little off for(bitrate_index=2; bitrate_index<30; bitrate_index++){ - frame_size = ff_mpa_bitrate_tab[lsf][2][bitrate_index>>1]; + frame_size = avpriv_mpa_bitrate_tab[lsf][2][bitrate_index>>1]; frame_size = (frame_size * 144000) / (sample_rate << lsf) + (bitrate_index&1); if(frame_size == buf_size + 4) break; diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index 180afb3967..9663db2f61 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -1290,8 +1290,8 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) assert((avctx->sub_id == 1) == (avctx->codec_id == CODEC_ID_MPEG1VIDEO)); if (avctx->codec_id == CODEC_ID_MPEG1VIDEO) { //MPEG-1 fps - avctx->time_base.den = ff_frame_rate_tab[s->frame_rate_index].num; - avctx->time_base.num = ff_frame_rate_tab[s->frame_rate_index].den; + avctx->time_base.den = avpriv_frame_rate_tab[s->frame_rate_index].num; + avctx->time_base.num = avpriv_frame_rate_tab[s->frame_rate_index].den; //MPEG-1 aspect avctx->sample_aspect_ratio = av_d2q(1.0/ff_mpeg1_aspect[s->aspect_ratio_info], 255); avctx->ticks_per_frame=1; @@ -1299,8 +1299,8 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) //MPEG-2 fps av_reduce(&s->avctx->time_base.den, &s->avctx->time_base.num, - ff_frame_rate_tab[s->frame_rate_index].num * s1->frame_rate_ext.num*2, - ff_frame_rate_tab[s->frame_rate_index].den * s1->frame_rate_ext.den, + avpriv_frame_rate_tab[s->frame_rate_index].num * s1->frame_rate_ext.num*2, + avpriv_frame_rate_tab[s->frame_rate_index].den * s1->frame_rate_ext.den, 1 << 30); avctx->ticks_per_frame = 2; //MPEG-2 aspect @@ -1732,7 +1732,7 @@ static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y, if (avctx->hwaccel) { const uint8_t *buf_end, *buf_start = *buf - 4; /* include start_code */ int start_code = -1; - buf_end = ff_find_start_code(buf_start + 2, *buf + buf_size, &start_code); + buf_end = avpriv_mpv_find_start_code(buf_start + 2, *buf + buf_size, &start_code); if (buf_end < *buf + buf_size) buf_end -= 4; s->mb_y = mb_y; @@ -1923,7 +1923,7 @@ static int slice_decode_thread(AVCodecContext *c, void *arg) return 0; start_code = -1; - buf = ff_find_start_code(buf, s->gb.buffer_end, &start_code); + buf = avpriv_mpv_find_start_code(buf, s->gb.buffer_end, &start_code); mb_y= (start_code - SLICE_MIN_START_CODE) << field_pic; if (s->picture_structure == PICT_BOTTOM_FIELD) mb_y++; @@ -2217,7 +2217,7 @@ int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size, } state++; } else { - i = ff_find_start_code(buf + i, buf + buf_size, &state) - buf - 1; + i = avpriv_mpv_find_start_code(buf + i, buf + buf_size, &state) - buf - 1; if (pc->frame_start_found == 0 && state >= SLICE_MIN_START_CODE && state <= SLICE_MAX_START_CODE) { i++; pc->frame_start_found = 4; @@ -2308,7 +2308,7 @@ static int decode_chunks(AVCodecContext *avctx, for (;;) { /* find next start code */ uint32_t start_code = -1; - buf_ptr = ff_find_start_code(buf_ptr, buf_end, &start_code); + buf_ptr = avpriv_mpv_find_start_code(buf_ptr, buf_end, &start_code); if (start_code > 0x1ff) { if (s2->pict_type != AV_PICTURE_TYPE_B || avctx->skip_frame <= AVDISCARD_DEFAULT) { if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_SLICE)) { diff --git a/libavcodec/mpeg12data.c b/libavcodec/mpeg12data.c index 8b1f563bf4..c40883692b 100644 --- a/libavcodec/mpeg12data.c +++ b/libavcodec/mpeg12data.c @@ -305,7 +305,7 @@ const uint8_t ff_mpeg12_mbMotionVectorTable[17][2] = { { 0xc, 10 }, }; -const AVRational ff_frame_rate_tab[] = { +const AVRational avpriv_frame_rate_tab[] = { { 0, 0}, {24000, 1001}, { 24, 1}, diff --git a/libavcodec/mpeg12data.h b/libavcodec/mpeg12data.h index 9695e9d41e..d4ef11e0c6 100644 --- a/libavcodec/mpeg12data.h +++ b/libavcodec/mpeg12data.h @@ -48,7 +48,7 @@ extern const uint8_t ff_mpeg12_mbPatTable[64][2]; extern const uint8_t ff_mpeg12_mbMotionVectorTable[17][2]; -extern const AVRational ff_frame_rate_tab[]; +extern const AVRational avpriv_frame_rate_tab[]; extern const float ff_mpeg1_aspect[16]; extern const AVRational ff_mpeg2_aspect[16]; diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index 1772ed79f6..4b9a222e16 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -121,7 +121,7 @@ static int find_frame_rate_index(MpegEncContext *s){ int64_t d; for(i=1;i<14;i++) { - int64_t n0= 1001LL/ff_frame_rate_tab[i].den*ff_frame_rate_tab[i].num*s->avctx->time_base.num; + int64_t n0= 1001LL/avpriv_frame_rate_tab[i].den*avpriv_frame_rate_tab[i].num*s->avctx->time_base.num; int64_t n1= 1001LL*s->avctx->time_base.den; if(s->avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL && i>=9) break; @@ -200,7 +200,7 @@ static av_cold int encode_init(AVCodecContext *avctx) static void put_header(MpegEncContext *s, int header) { - align_put_bits(&s->pb); + avpriv_align_put_bits(&s->pb); put_bits(&s->pb, 16, header>>16); put_sbits(&s->pb, 16, header); } @@ -219,7 +219,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s) if(aspect_ratio==0.0) aspect_ratio= 1.0; //pixel aspect 1:1 (VGA) if (s->current_picture.f.key_frame) { - AVRational framerate= ff_frame_rate_tab[s->frame_rate_index]; + AVRational framerate= avpriv_frame_rate_tab[s->frame_rate_index]; /* mpeg1 header repeated every gop */ put_header(s, SEQ_START_CODE); @@ -978,7 +978,7 @@ AVCodec ff_mpeg1video_encoder = { .init = encode_init, .encode = MPV_encode_picture, .close = MPV_encode_end, - .supported_framerates= ff_frame_rate_tab+1, + .supported_framerates= avpriv_frame_rate_tab+1, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .capabilities= CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, .long_name= NULL_IF_CONFIG_SMALL("MPEG-1 video"), @@ -993,7 +993,7 @@ AVCodec ff_mpeg2video_encoder = { .init = encode_init, .encode = MPV_encode_picture, .close = MPV_encode_end, - .supported_framerates= ff_frame_rate_tab+1, + .supported_framerates= avpriv_frame_rate_tab+1, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_NONE}, .capabilities= CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, .long_name= NULL_IF_CONFIG_SMALL("MPEG-2 video"), diff --git a/libavcodec/mpeg4audio.c b/libavcodec/mpeg4audio.c index f9951b1604..ac546ba137 100644 --- a/libavcodec/mpeg4audio.c +++ b/libavcodec/mpeg4audio.c @@ -52,7 +52,7 @@ static int parse_config_ALS(GetBitContext *gb, MPEG4AudioConfig *c) return 0; } -const int ff_mpeg4audio_sample_rates[16] = { +const int avpriv_mpeg4audio_sample_rates[16] = { 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350 }; @@ -73,10 +73,10 @@ static inline int get_sample_rate(GetBitContext *gb, int *index) { *index = get_bits(gb, 4); return *index == 0x0f ? get_bits(gb, 24) : - ff_mpeg4audio_sample_rates[*index]; + avpriv_mpeg4audio_sample_rates[*index]; } -int ff_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int buf_size) +int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int buf_size) { GetBitContext gb; int specific_config_bitindex; @@ -151,7 +151,7 @@ static av_always_inline unsigned int copy_bits(PutBitContext *pb, return el; } -int ff_copy_pce_data(PutBitContext *pb, GetBitContext *gb) +int avpriv_copy_pce_data(PutBitContext *pb, GetBitContext *gb) { int five_bit_ch, four_bit_ch, comment_size, bits; int offset = put_bits_count(pb); @@ -173,7 +173,7 @@ int ff_copy_pce_data(PutBitContext *pb, GetBitContext *gb) copy_bits(pb, gb, 16); if (bits) copy_bits(pb, gb, bits); - align_put_bits(pb); + avpriv_align_put_bits(pb); align_get_bits(gb); comment_size = copy_bits(pb, gb, 8); for (; comment_size > 0; comment_size--) diff --git a/libavcodec/mpeg4audio.h b/libavcodec/mpeg4audio.h index f70049a0e8..3d1f7e0c4c 100644 --- a/libavcodec/mpeg4audio.h +++ b/libavcodec/mpeg4audio.h @@ -40,7 +40,7 @@ typedef struct { int ps; ///< -1 implicit, 1 presence } MPEG4AudioConfig; -extern const int ff_mpeg4audio_sample_rates[16]; +extern const int avpriv_mpeg4audio_sample_rates[16]; extern const uint8_t ff_mpeg4audio_channels[8]; /** * Parse MPEG-4 systems extradata to retrieve audio configuration. @@ -49,7 +49,7 @@ extern const uint8_t ff_mpeg4audio_channels[8]; * @param[in] buf_size Extradata size. * @return On error -1 is returned, on success AudioSpecificConfig bit index in extradata. */ -int ff_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int buf_size); +int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int buf_size); enum AudioObjectType { AOT_NULL, @@ -101,6 +101,6 @@ enum AudioObjectType { #define MAX_PCE_SIZE 304 ///<Maximum size of a PCE including the 3-bit ID_PCE ///<marker and the comment -int ff_copy_pce_data(PutBitContext *pb, GetBitContext *gb); +int avpriv_copy_pce_data(PutBitContext *pb, GetBitContext *gb); #endif /* AVCODEC_MPEG4AUDIO_H */ diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index b39a7e7416..dac9a9c885 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -1268,8 +1268,8 @@ void ff_mpeg4_merge_partitions(MpegEncContext *s) flush_put_bits(&s->tex_pb); set_put_bits_buffer_size(&s->pb, s->pb2.buf_end - s->pb.buf); - ff_copy_bits(&s->pb, s->pb2.buf , pb2_len); - ff_copy_bits(&s->pb, s->tex_pb.buf, tex_pb_len); + avpriv_copy_bits(&s->pb, s->pb2.buf , pb2_len); + avpriv_copy_bits(&s->pb, s->tex_pb.buf, tex_pb_len); s->last_bits= put_bits_count(&s->pb); } diff --git a/libavcodec/mpegaudio_parser.c b/libavcodec/mpegaudio_parser.c index 9c19d6ffdb..b13b7881ca 100644 --- a/libavcodec/mpegaudio_parser.c +++ b/libavcodec/mpegaudio_parser.c @@ -64,7 +64,7 @@ static int mpegaudio_parse(AVCodecParserContext *s1, state= (state<<8) + buf[i++]; - ret = ff_mpa_decode_header(avctx, state, &sr, &channels, &frame_size, &bit_rate); + ret = avpriv_mpa_decode_header(avctx, state, &sr, &channels, &frame_size, &bit_rate); if (ret < 4) { if(i > 4) s->header_count= -2; diff --git a/libavcodec/mpegaudiodata.c b/libavcodec/mpegaudiodata.c index c9dabf3185..32299a47cf 100644 --- a/libavcodec/mpegaudiodata.c +++ b/libavcodec/mpegaudiodata.c @@ -27,7 +27,7 @@ #include "mpegaudiodata.h" -const uint16_t ff_mpa_bitrate_tab[2][3][15] = { +const uint16_t avpriv_mpa_bitrate_tab[2][3][15] = { { {0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448 }, {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384 }, {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] = { } }; -const uint16_t ff_mpa_freq_tab[3] = { 44100, 48000, 32000 }; +const uint16_t avpriv_mpa_freq_tab[3] = { 44100, 48000, 32000 }; /*******************************************************/ /* half mpeg encoding window (full precision) */ diff --git a/libavcodec/mpegaudiodata.h b/libavcodec/mpegaudiodata.h index 9d65a1e2a6..71645a668d 100644 --- a/libavcodec/mpegaudiodata.h +++ b/libavcodec/mpegaudiodata.h @@ -32,8 +32,8 @@ #define MODE_EXT_MS_STEREO 2 #define MODE_EXT_I_STEREO 1 -extern const uint16_t ff_mpa_bitrate_tab[2][3][15]; -extern const uint16_t ff_mpa_freq_tab[3]; +extern const uint16_t avpriv_mpa_bitrate_tab[2][3][15]; +extern const uint16_t avpriv_mpa_freq_tab[3]; extern const int32_t ff_mpa_enwindow[257]; extern const int ff_mpa_sblimit_table[5]; extern const int ff_mpa_quant_steps[17]; diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c index 7c98cde587..b5ba285bc9 100644 --- a/libavcodec/mpegaudiodec.c +++ b/libavcodec/mpegaudiodec.c @@ -1789,7 +1789,7 @@ static int decode_frame(AVCodecContext * avctx, return -1; } - if (ff_mpegaudio_decode_header((MPADecodeHeader *)s, header) == 1) { + if (avpriv_mpegaudio_decode_header((MPADecodeHeader *)s, header) == 1) { /* free format: prepare to compute frame size */ s->frame_size = -1; return -1; @@ -1862,7 +1862,7 @@ static int decode_frame_adu(AVCodecContext * avctx, return buf_size; } - ff_mpegaudio_decode_header((MPADecodeHeader *)s, header); + avpriv_mpegaudio_decode_header((MPADecodeHeader *)s, header); /* update codec info */ avctx->sample_rate = s->sample_rate; avctx->channels = s->nb_channels; @@ -1923,7 +1923,7 @@ static int decode_init_mp3on4(AVCodecContext * avctx) return -1; } - ff_mpeg4audio_get_config(&cfg, avctx->extradata, avctx->extradata_size); + avpriv_mpeg4audio_get_config(&cfg, avctx->extradata, avctx->extradata_size); if (!cfg.chan_config || cfg.chan_config > 7) { av_log(avctx, AV_LOG_ERROR, "Invalid channel config number.\n"); return -1; @@ -2015,7 +2015,7 @@ static int decode_frame_mp3on4(AVCodecContext * avctx, if (ff_mpa_check_header(header) < 0) // Bad header, discard block break; - ff_mpegaudio_decode_header((MPADecodeHeader *)m, header); + avpriv_mpegaudio_decode_header((MPADecodeHeader *)m, header); out_size += mp_decode_frame(m, outptr, buf, fsize); buf += fsize; len -= fsize; diff --git a/libavcodec/mpegaudiodecheader.c b/libavcodec/mpegaudiodecheader.c index 1c3b004bcc..24919ab544 100644 --- a/libavcodec/mpegaudiodecheader.c +++ b/libavcodec/mpegaudiodecheader.c @@ -31,7 +31,7 @@ #include "mpegaudiodecheader.h" -int ff_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header) +int avpriv_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header) { int sample_rate, frame_size, mpeg25, padding; int sample_rate_index, bitrate_index; @@ -46,7 +46,7 @@ int ff_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header) s->layer = 4 - ((header >> 17) & 3); /* extract frequency */ sample_rate_index = (header >> 10) & 3; - sample_rate = ff_mpa_freq_tab[sample_rate_index] >> (s->lsf + mpeg25); + sample_rate = avpriv_mpa_freq_tab[sample_rate_index] >> (s->lsf + mpeg25); sample_rate_index += 3 * (s->lsf + mpeg25); s->sample_rate_index = sample_rate_index; s->error_protection = ((header >> 16) & 1) ^ 1; @@ -67,7 +67,7 @@ int ff_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header) s->nb_channels = 2; if (bitrate_index != 0) { - frame_size = ff_mpa_bitrate_tab[s->lsf][s->layer - 1][bitrate_index]; + frame_size = avpriv_mpa_bitrate_tab[s->lsf][s->layer - 1][bitrate_index]; s->bit_rate = frame_size * 1000; switch(s->layer) { case 1: @@ -109,14 +109,14 @@ int ff_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header) return 0; } -int ff_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bit_rate) +int avpriv_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bit_rate) { MPADecodeHeader s1, *s = &s1; if (ff_mpa_check_header(head) != 0) return -1; - if (ff_mpegaudio_decode_header(s, head) != 0) { + if (avpriv_mpegaudio_decode_header(s, head) != 0) { return -1; } diff --git a/libavcodec/mpegaudiodecheader.h b/libavcodec/mpegaudiodecheader.h index aa77f0122e..c434d00441 100644 --- a/libavcodec/mpegaudiodecheader.h +++ b/libavcodec/mpegaudiodecheader.h @@ -50,11 +50,11 @@ typedef struct MPADecodeHeader { /* header decoding. MUST check the header before because no consistency check is done there. Return 1 if free format found and that the frame size must be computed externally */ -int ff_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header); +int avpriv_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header); /* useful helper to get mpeg audio stream infos. Return -1 if error in header, otherwise the coded frame size in bytes */ -int ff_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bitrate); +int avpriv_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bitrate); /* fast header check for resync */ static inline int ff_mpa_check_header(uint32_t header){ diff --git a/libavcodec/mpegaudioenc.c b/libavcodec/mpegaudioenc.c index cc814091ec..6b71d01ae9 100644 --- a/libavcodec/mpegaudioenc.c +++ b/libavcodec/mpegaudioenc.c @@ -84,9 +84,9 @@ static av_cold int MPA_encode_init(AVCodecContext *avctx) /* encoding freq */ s->lsf = 0; for(i=0;i<3;i++) { - if (ff_mpa_freq_tab[i] == freq) + if (avpriv_mpa_freq_tab[i] == freq) break; - if ((ff_mpa_freq_tab[i] / 2) == freq) { + if ((avpriv_mpa_freq_tab[i] / 2) == freq) { s->lsf = 1; break; } @@ -99,7 +99,7 @@ static av_cold int MPA_encode_init(AVCodecContext *avctx) /* encoding bitrate & frequency */ for(i=0;i<15;i++) { - if (ff_mpa_bitrate_tab[s->lsf][1][i] == bitrate) + if (avpriv_mpa_bitrate_tab[s->lsf][1][i] == bitrate) break; } if (i == 15){ diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 7f0fa2498e..fffa36a456 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -122,7 +122,7 @@ const enum PixelFormat ff_hwaccel_pixfmt_list_420[] = { PIX_FMT_NONE }; -const uint8_t *ff_find_start_code(const uint8_t * restrict p, const uint8_t *end, uint32_t * restrict state){ +const uint8_t *avpriv_mpv_find_start_code(const uint8_t * restrict p, const uint8_t *end, uint32_t * restrict state){ int i; assert(p<=end); @@ -645,9 +645,8 @@ av_cold int MPV_common_init(MpegEncContext *s) yc_size = y_size + 2 * c_size; /* convert fourcc to upper case */ - s->codec_tag = ff_toupper4(s->avctx->codec_tag); - - s->stream_codec_tag = ff_toupper4(s->avctx->stream_codec_tag); + s->codec_tag = avpriv_toupper4(s->avctx->codec_tag); + s->stream_codec_tag = avpriv_toupper4(s->avctx->stream_codec_tag); s->avctx->coded_frame= (AVFrame*)&s->current_picture; diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index f640c8e315..d97212c358 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -725,7 +725,7 @@ void ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src); int MPV_lowest_referenced_row(MpegEncContext *s, int dir); void MPV_report_decode_progress(MpegEncContext *s); int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src); -const uint8_t *ff_find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state); +const uint8_t *avpriv_mpv_find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state); void ff_set_qscale(MpegEncContext * s, int qscale); void ff_er_frame_start(MpegEncContext *s); diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 2925c2f780..7195e200e4 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -2051,7 +2051,7 @@ static void write_slice_end(MpegEncContext *s){ ff_mjpeg_encode_stuffing(&s->pb); } - align_put_bits(&s->pb); + avpriv_align_put_bits(&s->pb); flush_put_bits(&s->pb); if((s->flags&CODEC_FLAG_PASS1) && !s->partitioned_frame) @@ -2492,18 +2492,18 @@ static int encode_thread(AVCodecContext *c, void *arg){ pb_bits_count= put_bits_count(&s->pb); flush_put_bits(&s->pb); - ff_copy_bits(&backup_s.pb, bit_buf[next_block^1], pb_bits_count); + avpriv_copy_bits(&backup_s.pb, bit_buf[next_block^1], pb_bits_count); s->pb= backup_s.pb; if(s->data_partitioning){ pb2_bits_count= put_bits_count(&s->pb2); flush_put_bits(&s->pb2); - ff_copy_bits(&backup_s.pb2, bit_buf2[next_block^1], pb2_bits_count); + avpriv_copy_bits(&backup_s.pb2, bit_buf2[next_block^1], pb2_bits_count); s->pb2= backup_s.pb2; tex_pb_bits_count= put_bits_count(&s->tex_pb); flush_put_bits(&s->tex_pb); - ff_copy_bits(&backup_s.tex_pb, bit_buf_tex[next_block^1], tex_pb_bits_count); + avpriv_copy_bits(&backup_s.tex_pb, bit_buf_tex[next_block^1], tex_pb_bits_count); s->tex_pb= backup_s.tex_pb; } s->last_bits= put_bits_count(&s->pb); @@ -2726,7 +2726,7 @@ static void merge_context_after_encode(MpegEncContext *dst, MpegEncContext *src) assert(put_bits_count(&src->pb) % 8 ==0); assert(put_bits_count(&dst->pb) % 8 ==0); - ff_copy_bits(&dst->pb, src->pb.buf, put_bits_count(&src->pb)); + avpriv_copy_bits(&dst->pb, src->pb.buf, put_bits_count(&src->pb)); flush_put_bits(&dst->pb); } diff --git a/libavcodec/mpegvideo_parser.c b/libavcodec/mpegvideo_parser.c index 25028a9eb1..ce55cdd13c 100644 --- a/libavcodec/mpegvideo_parser.c +++ b/libavcodec/mpegvideo_parser.c @@ -40,7 +40,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, while (buf < buf_end) { start_code= -1; - buf= ff_find_start_code(buf, buf_end, &start_code); + buf= avpriv_mpv_find_start_code(buf, buf_end, &start_code); bytes_left = buf_end - buf; switch(start_code) { case PICTURE_START_CODE: @@ -57,8 +57,8 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, did_set_size=1; } frame_rate_index = buf[3] & 0xf; - pc->frame_rate.den = avctx->time_base.den = ff_frame_rate_tab[frame_rate_index].num; - pc->frame_rate.num = avctx->time_base.num = ff_frame_rate_tab[frame_rate_index].den; + pc->frame_rate.den = avctx->time_base.den = avpriv_frame_rate_tab[frame_rate_index].num; + pc->frame_rate.num = avctx->time_base.num = avpriv_frame_rate_tab[frame_rate_index].den; avctx->bit_rate = ((buf[4]<<10) | (buf[5]<<2) | (buf[6]>>6))*400; avctx->codec_id = CODEC_ID_MPEG1VIDEO; avctx->sub_id = 1; diff --git a/libavcodec/msmpeg4.c b/libavcodec/msmpeg4.c index 35ffb387a6..5b762898af 100644 --- a/libavcodec/msmpeg4.c +++ b/libavcodec/msmpeg4.c @@ -351,7 +351,7 @@ void msmpeg4_encode_picture_header(MpegEncContext * s, int picture_number) { find_best_tables(s); - align_put_bits(&s->pb); + avpriv_align_put_bits(&s->pb); put_bits(&s->pb, 2, s->pict_type - 1); put_bits(&s->pb, 5, s->qscale); diff --git a/libavcodec/put_bits.h b/libavcodec/put_bits.h index 7384fba4e4..9256e7fa4d 100644 --- a/libavcodec/put_bits.h +++ b/libavcodec/put_bits.h @@ -97,14 +97,14 @@ static inline void flush_put_bits(PutBitContext *s) } #ifdef BITSTREAM_WRITER_LE -#define align_put_bits align_put_bits_unsupported_here +#define avpriv_align_put_bits align_put_bits_unsupported_here #define ff_put_string ff_put_string_unsupported_here -#define ff_copy_bits ff_copy_bits_unsupported_here +#define avpriv_copy_bits avpriv_copy_bits_unsupported_here #else /** * Pad the bitstream with zeros up to the next byte boundary. */ -void align_put_bits(PutBitContext *s); +void avpriv_align_put_bits(PutBitContext *s); /** * Put the string string in the bitstream. @@ -118,7 +118,7 @@ void ff_put_string(PutBitContext *pb, const char *string, int terminate_string); * * @param length the number of bits of src to copy */ -void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length); +void avpriv_copy_bits(PutBitContext *pb, const uint8_t *src, int length); #endif /** diff --git a/libavcodec/rv10enc.c b/libavcodec/rv10enc.c index db9043ceea..8dd74e844e 100644 --- a/libavcodec/rv10enc.c +++ b/libavcodec/rv10enc.c @@ -32,7 +32,7 @@ void rv10_encode_picture_header(MpegEncContext *s, int picture_number) { int full_frame= 0; - align_put_bits(&s->pb); + avpriv_align_put_bits(&s->pb); put_bits(&s->pb, 1, 1); /* marker */ diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c index 15afc42a61..df1daebb33 100644 --- a/libavcodec/shorten.c +++ b/libavcodec/shorten.c @@ -28,6 +28,7 @@ #include <limits.h> #include "avcodec.h" +#include "bytestream.h" #include "get_bits.h" #include "golomb.h" @@ -69,6 +70,9 @@ #define FN_ZERO 8 #define FN_VERBATIM 9 +/** indicates if the FN_* command is audio or non-audio */ +static const uint8_t is_audio_command[10] = { 1, 1, 1, 1, 0, 0, 0, 1, 1, 0 }; + #define VERBATIM_CKSIZE_SIZE 5 #define VERBATIM_BYTE_SIZE 8 #define CANONICAL_HEADER_SIZE 44 @@ -98,6 +102,8 @@ typedef struct ShortenContext { int blocksize; int bitindex; int32_t lpcqoffset; + int got_header; + int got_quit_command; } ShortenContext; static av_cold int shorten_decode_init(AVCodecContext * avctx) @@ -113,6 +119,7 @@ static int allocate_buffers(ShortenContext *s) { int i, chan; int *coeffs; + void *tmp_ptr; for (chan=0; chan<s->channels; chan++) { if(FFMAX(1, s->nmean) >= UINT_MAX/sizeof(int32_t)){ @@ -124,9 +131,15 @@ static int allocate_buffers(ShortenContext *s) return -1; } - s->offset[chan] = av_realloc(s->offset[chan], sizeof(int32_t)*FFMAX(1, s->nmean)); + tmp_ptr = av_realloc(s->offset[chan], sizeof(int32_t)*FFMAX(1, s->nmean)); + if (!tmp_ptr) + return AVERROR(ENOMEM); + s->offset[chan] = tmp_ptr; - s->decoded[chan] = av_realloc(s->decoded[chan], sizeof(int32_t)*(s->blocksize + s->nwrap)); + tmp_ptr = av_realloc(s->decoded[chan], sizeof(int32_t)*(s->blocksize + s->nwrap)); + if (!tmp_ptr) + return AVERROR(ENOMEM); + s->decoded[chan] = tmp_ptr; for (i=0; i<s->nwrap; i++) s->decoded[chan][i] = 0; s->decoded[chan] += s->nwrap; @@ -181,47 +194,37 @@ static void init_offset(ShortenContext *s) s->offset[chan][i] = mean; } -static inline int get_le32(GetBitContext *gb) -{ - return av_bswap32(get_bits_long(gb, 32)); -} - -static inline short get_le16(GetBitContext *gb) -{ - return av_bswap16(get_bits_long(gb, 16)); -} - -static int decode_wave_header(AVCodecContext *avctx, uint8_t *header, int header_size) +static int decode_wave_header(AVCodecContext *avctx, const uint8_t *header, + int header_size) { - GetBitContext hb; int len; short wave_format; - init_get_bits(&hb, header, header_size*8); - if (get_le32(&hb) != MKTAG('R','I','F','F')) { + + if (bytestream_get_le32(&header) != MKTAG('R','I','F','F')) { av_log(avctx, AV_LOG_ERROR, "missing RIFF tag\n"); return -1; } - skip_bits_long(&hb, 32); /* chunk_size */ + header += 4; /* chunk size */; - if (get_le32(&hb) != MKTAG('W','A','V','E')) { + if (bytestream_get_le32(&header) != MKTAG('W','A','V','E')) { av_log(avctx, AV_LOG_ERROR, "missing WAVE tag\n"); return -1; } - while (get_le32(&hb) != MKTAG('f','m','t',' ')) { - len = get_le32(&hb); - skip_bits(&hb, 8*len); + while (bytestream_get_le32(&header) != MKTAG('f','m','t',' ')) { + len = bytestream_get_le32(&header); + header += len; } - len = get_le32(&hb); + len = bytestream_get_le32(&header); if (len < 16) { av_log(avctx, AV_LOG_ERROR, "fmt chunk was too short\n"); return -1; } - wave_format = get_le16(&hb); + wave_format = bytestream_get_le16(&header); switch (wave_format) { case WAVE_FORMAT_PCM: @@ -231,11 +234,11 @@ static int decode_wave_header(AVCodecContext *avctx, uint8_t *header, int header return -1; } - avctx->channels = get_le16(&hb); - avctx->sample_rate = get_le32(&hb); - avctx->bit_rate = get_le32(&hb) * 8; - avctx->block_align = get_le16(&hb); - avctx->bits_per_coded_sample = get_le16(&hb); + header += 2; // skip channels (already got from shorten header) + avctx->sample_rate = bytestream_get_le32(&header); + header += 4; // skip bit rate (represents original uncompressed bit rate) + header += 2; // skip block align (not needed) + avctx->bits_per_coded_sample = bytestream_get_le16(&header); if (avctx->bits_per_coded_sample != 16) { 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 int i, chan; for (i=0; i<blocksize; i++) for (chan=0; chan < nchan; chan++) - *samples++ = FFMIN(buffer[chan][i], 32768); + *samples++ = av_clip_int16(buffer[chan][i]); return samples; } -static void decode_subframe_lpc(ShortenContext *s, int channel, int residual_size, int pred_order) +static const int fixed_coeffs[3][3] = { + { 1, 0, 0 }, + { 2, -1, 0 }, + { 3, -3, 1 } +}; + +static int decode_subframe_lpc(ShortenContext *s, int command, int channel, + int residual_size, int32_t coffset) { - int sum, i, j; - int *coeffs = s->coeffs; + int pred_order, sum, qshift, init_sum, i, j; + const int *coeffs; + + if (command == FN_QLPC) { + /* read/validate prediction order */ + pred_order = get_ur_golomb_shorten(&s->gb, LPCQSIZE); + if (pred_order > s->nwrap) { + av_log(s->avctx, AV_LOG_ERROR, "invalid pred_order %d\n", pred_order); + return AVERROR(EINVAL); + } + /* read LPC coefficients */ + for (i=0; i<pred_order; i++) + s->coeffs[i] = get_sr_golomb_shorten(&s->gb, LPCQUANT); + coeffs = s->coeffs; + + qshift = LPCQUANT; + } else { + /* fixed LPC coeffs */ + pred_order = command; + coeffs = fixed_coeffs[pred_order-1]; + qshift = 0; + } - for (i=0; i<pred_order; i++) - coeffs[i] = get_sr_golomb_shorten(&s->gb, LPCQUANT); + /* subtract offset from previous samples to use in prediction */ + if (command == FN_QLPC && coffset) + for (i = -pred_order; i < 0; i++) + s->decoded[channel][i] -= coffset; + /* decode residual and do LPC prediction */ + init_sum = pred_order ? (command == FN_QLPC ? s->lpcqoffset : 0) : coffset; for (i=0; i < s->blocksize; i++) { - sum = s->lpcqoffset; + sum = init_sum; for (j=0; j<pred_order; j++) sum += coeffs[j] * s->decoded[channel][i-j-1]; - s->decoded[channel][i] = get_sr_golomb_shorten(&s->gb, residual_size) + (sum >> LPCQUANT); + s->decoded[channel][i] = get_sr_golomb_shorten(&s->gb, residual_size) + (sum >> qshift); } + + /* add offset to current samples */ + if (command == FN_QLPC && coffset) + for (i = 0; i < s->blocksize; i++) + s->decoded[channel][i] += coffset; + + return 0; } +static int read_header(ShortenContext *s) +{ + int i, ret; + int maxnlpc = 0; + /* shorten signature */ + if (get_bits_long(&s->gb, 32) != AV_RB32("ajkg")) { + av_log(s->avctx, AV_LOG_ERROR, "missing shorten magic 'ajkg'\n"); + return -1; + } + + s->lpcqoffset = 0; + s->blocksize = DEFAULT_BLOCK_SIZE; + s->channels = 1; + s->nmean = -1; + s->version = get_bits(&s->gb, 8); + s->internal_ftype = get_uint(s, TYPESIZE); + + s->channels = get_uint(s, CHANSIZE); + if (s->channels > MAX_CHANNELS) { + av_log(s->avctx, AV_LOG_ERROR, "too many channels: %d\n", s->channels); + return -1; + } + s->avctx->channels = s->channels; + + /* get blocksize if version > 0 */ + if (s->version > 0) { + int skip_bytes, blocksize; + + blocksize = get_uint(s, av_log2(DEFAULT_BLOCK_SIZE)); + if (!blocksize || blocksize > MAX_BLOCKSIZE) { + av_log(s->avctx, AV_LOG_ERROR, "invalid or unsupported block size: %d\n", + blocksize); + return AVERROR(EINVAL); + } + s->blocksize = blocksize; + + maxnlpc = get_uint(s, LPCQSIZE); + s->nmean = get_uint(s, 0); + + skip_bytes = get_uint(s, NSKIPSIZE); + for (i=0; i<skip_bytes; i++) { + skip_bits(&s->gb, 8); + } + } + s->nwrap = FFMAX(NWRAP, maxnlpc); + + if ((ret = allocate_buffers(s)) < 0) + return ret; + + init_offset(s); + + if (s->version > 1) + s->lpcqoffset = V2LPCQOFFSET; + + if (get_ur_golomb_shorten(&s->gb, FNSIZE) != FN_VERBATIM) { + av_log(s->avctx, AV_LOG_ERROR, "missing verbatim section at beginning of stream\n"); + return -1; + } + + s->header_size = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE); + if (s->header_size >= OUT_BUFFER_SIZE || s->header_size < CANONICAL_HEADER_SIZE) { + av_log(s->avctx, AV_LOG_ERROR, "header is wrong size: %d\n", s->header_size); + return -1; + } + + for (i=0; i<s->header_size; i++) + s->header[i] = (char)get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE); + + if (decode_wave_header(s->avctx, s->header, s->header_size) < 0) + return -1; + + s->cur_chan = 0; + s->bitshift = 0; + + s->got_header = 1; + + return 0; +} static int shorten_decode_frame(AVCodecContext *avctx, void *data, int *data_size, @@ -283,226 +402,189 @@ static int shorten_decode_frame(AVCodecContext *avctx, ShortenContext *s = avctx->priv_data; int i, input_buf_size = 0; int16_t *samples = data; + int ret; + + /* allocate internal bitstream buffer */ if(s->max_framesize == 0){ + void *tmp_ptr; s->max_framesize= 1024; // should hopefully be enough for the first header - s->bitstream= av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, s->max_framesize); + tmp_ptr = av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, + s->max_framesize); + if (!tmp_ptr) { + av_log(avctx, AV_LOG_ERROR, "error allocating bitstream buffer\n"); + return AVERROR(ENOMEM); + } + s->bitstream = tmp_ptr; } + /* append current packet data to bitstream buffer */ if(1 && s->max_framesize){//FIXME truncated buf_size= FFMIN(buf_size, s->max_framesize - s->bitstream_size); input_buf_size= buf_size; if(s->bitstream_index + s->bitstream_size + buf_size > s->allocated_bitstream_size){ - // printf("memmove\n"); memmove(s->bitstream, &s->bitstream[s->bitstream_index], s->bitstream_size); s->bitstream_index=0; } - memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size], buf, buf_size); + if (buf) + memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size], buf, buf_size); buf= &s->bitstream[s->bitstream_index]; buf_size += s->bitstream_size; s->bitstream_size= buf_size; - if(buf_size < s->max_framesize){ + /* do not decode until buffer has at least max_framesize bytes or + the end of the file has been reached */ + if (buf_size < s->max_framesize && avpkt->data) { *data_size = 0; return input_buf_size; } } + /* init and position bitstream reader */ init_get_bits(&s->gb, buf, buf_size*8); skip_bits(&s->gb, s->bitindex); - if (!s->blocksize) - { - int maxnlpc = 0; - /* shorten signature */ - if (get_bits_long(&s->gb, 32) != AV_RB32("ajkg")) { - av_log(s->avctx, AV_LOG_ERROR, "missing shorten magic 'ajkg'\n"); - return -1; - } - s->lpcqoffset = 0; - s->blocksize = DEFAULT_BLOCK_SIZE; - s->channels = 1; - s->nmean = -1; - s->version = get_bits(&s->gb, 8); - s->internal_ftype = get_uint(s, TYPESIZE); + /* process header or next subblock */ + if (!s->got_header) { + if ((ret = read_header(s)) < 0) + return ret; + *data_size = 0; + goto finish_frame; + } - s->channels = get_uint(s, CHANSIZE); - if (s->channels > MAX_CHANNELS) { - av_log(s->avctx, AV_LOG_ERROR, "too many channels: %d\n", s->channels); - return -1; - } + /* if quit command was read previously, don't decode anything */ + if (s->got_quit_command) { + *data_size = 0; + return avpkt->size; + } - /* get blocksize if version > 0 */ - if (s->version > 0) { - int skip_bytes; - s->blocksize = get_uint(s, av_log2(DEFAULT_BLOCK_SIZE)); - maxnlpc = get_uint(s, LPCQSIZE); - s->nmean = get_uint(s, 0); + s->cur_chan = 0; + while (s->cur_chan < s->channels) { + int cmd; + int len; - skip_bytes = get_uint(s, NSKIPSIZE); - for (i=0; i<skip_bytes; i++) { - skip_bits(&s->gb, 8); - } + if (get_bits_left(&s->gb) < 3+FNSIZE) { + *data_size = 0; + break; } - s->nwrap = FFMAX(NWRAP, maxnlpc); - - if (allocate_buffers(s)) - return -1; - init_offset(s); - - if (s->version > 1) - s->lpcqoffset = V2LPCQOFFSET; + cmd = get_ur_golomb_shorten(&s->gb, FNSIZE); - if (get_ur_golomb_shorten(&s->gb, FNSIZE) != FN_VERBATIM) { - av_log(s->avctx, AV_LOG_ERROR, "missing verbatim section at beginning of stream\n"); - return -1; + if (cmd > FN_VERBATIM) { + av_log(avctx, AV_LOG_ERROR, "unknown shorten function %d\n", cmd); + *data_size = 0; + break; } - s->header_size = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE); - if (s->header_size >= OUT_BUFFER_SIZE || s->header_size < CANONICAL_HEADER_SIZE) { - av_log(s->avctx, AV_LOG_ERROR, "header is wrong size: %d\n", s->header_size); - return -1; - } + if (!is_audio_command[cmd]) { + /* process non-audio command */ + switch (cmd) { + case FN_VERBATIM: + len = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE); + while (len--) { + get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE); + } + break; + case FN_BITSHIFT: + s->bitshift = get_ur_golomb_shorten(&s->gb, BITSHIFTSIZE); + break; + case FN_BLOCKSIZE: { + int blocksize = get_uint(s, av_log2(s->blocksize)); + if (blocksize > s->blocksize) { + av_log(avctx, AV_LOG_ERROR, "Increasing block size is not supported\n"); + return AVERROR_PATCHWELCOME; + } + if (!blocksize || blocksize > MAX_BLOCKSIZE) { + av_log(avctx, AV_LOG_ERROR, "invalid or unsupported " + "block size: %d\n", blocksize); + return AVERROR(EINVAL); + } + s->blocksize = blocksize; + break; + } + case FN_QUIT: + s->got_quit_command = 1; + break; + } + if (cmd == FN_BLOCKSIZE || cmd == FN_QUIT) { + *data_size = 0; + break; + } + } else { + /* process audio command */ + int residual_size = 0; + int channel = s->cur_chan; + int32_t coffset; + + /* get Rice code for residual decoding */ + if (cmd != FN_ZERO) { + residual_size = get_ur_golomb_shorten(&s->gb, ENERGYSIZE); + /* this is a hack as version 0 differed in defintion of get_sr_golomb_shorten */ + if (s->version == 0) + residual_size--; + } - for (i=0; i<s->header_size; i++) - s->header[i] = (char)get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE); + /* calculate sample offset using means from previous blocks */ + if (s->nmean == 0) + coffset = s->offset[channel][0]; + else { + int32_t sum = (s->version < 2) ? 0 : s->nmean / 2; + for (i=0; i<s->nmean; i++) + sum += s->offset[channel][i]; + coffset = sum / s->nmean; + if (s->version >= 2) + coffset >>= FFMIN(1, s->bitshift); + } - if (decode_wave_header(avctx, s->header, s->header_size) < 0) - return -1; + /* decode samples for this channel */ + if (cmd == FN_ZERO) { + for (i=0; i<s->blocksize; i++) + s->decoded[channel][i] = 0; + } else { + if ((ret = decode_subframe_lpc(s, cmd, channel, residual_size, coffset)) < 0) + return ret; + } - s->cur_chan = 0; - s->bitshift = 0; - } - else - { - int cmd; - int len; - cmd = get_ur_golomb_shorten(&s->gb, FNSIZE); - switch (cmd) { - case FN_ZERO: - case FN_DIFF0: - case FN_DIFF1: - case FN_DIFF2: - case FN_DIFF3: - case FN_QLPC: - { - int residual_size = 0; - int channel = s->cur_chan; - int32_t coffset; - if (cmd != FN_ZERO) { - residual_size = get_ur_golomb_shorten(&s->gb, ENERGYSIZE); - /* this is a hack as version 0 differed in defintion of get_sr_golomb_shorten */ - if (s->version == 0) - residual_size--; - } + /* update means with info from the current block */ + if (s->nmean > 0) { + int32_t sum = (s->version < 2) ? 0 : s->blocksize / 2; + for (i=0; i<s->blocksize; i++) + sum += s->decoded[channel][i]; - if (s->nmean == 0) - coffset = s->offset[channel][0]; - else { - int32_t sum = (s->version < 2) ? 0 : s->nmean / 2; - for (i=0; i<s->nmean; i++) - sum += s->offset[channel][i]; - coffset = sum / s->nmean; - if (s->version >= 2) - coffset >>= FFMIN(1, s->bitshift); - } - switch (cmd) { - case FN_ZERO: - for (i=0; i<s->blocksize; i++) - s->decoded[channel][i] = 0; - break; - case FN_DIFF0: - for (i=0; i<s->blocksize; i++) - s->decoded[channel][i] = get_sr_golomb_shorten(&s->gb, residual_size) + coffset; - break; - case FN_DIFF1: - for (i=0; i<s->blocksize; i++) - s->decoded[channel][i] = get_sr_golomb_shorten(&s->gb, residual_size) + s->decoded[channel][i - 1]; - break; - case FN_DIFF2: - for (i=0; i<s->blocksize; i++) - s->decoded[channel][i] = get_sr_golomb_shorten(&s->gb, residual_size) + 2*s->decoded[channel][i-1] - - s->decoded[channel][i-2]; - break; - case FN_DIFF3: - for (i=0; i<s->blocksize; i++) - s->decoded[channel][i] = get_sr_golomb_shorten(&s->gb, residual_size) + 3*s->decoded[channel][i-1] - - 3*s->decoded[channel][i-2] - + s->decoded[channel][i-3]; - break; - case FN_QLPC: - { - int pred_order = get_ur_golomb_shorten(&s->gb, LPCQSIZE); - if (pred_order > s->nwrap) { - av_log(avctx, AV_LOG_ERROR, - "invalid pred_order %d\n", - pred_order); - return -1; - } - for (i=0; i<pred_order; i++) - s->decoded[channel][i - pred_order] -= coffset; - decode_subframe_lpc(s, channel, residual_size, pred_order); - if (coffset != 0) - for (i=0; i < s->blocksize; i++) - s->decoded[channel][i] += coffset; - } - } - if (s->nmean > 0) { - int32_t sum = (s->version < 2) ? 0 : s->blocksize / 2; - for (i=0; i<s->blocksize; i++) - sum += s->decoded[channel][i]; - - for (i=1; i<s->nmean; i++) - s->offset[channel][i-1] = s->offset[channel][i]; - - if (s->version < 2) - s->offset[channel][s->nmean - 1] = sum / s->blocksize; - else - s->offset[channel][s->nmean - 1] = (sum / s->blocksize) << s->bitshift; - } - for (i=-s->nwrap; i<0; i++) - s->decoded[channel][i] = s->decoded[channel][i + s->blocksize]; + for (i=1; i<s->nmean; i++) + s->offset[channel][i-1] = s->offset[channel][i]; - fix_bitshift(s, s->decoded[channel]); + if (s->version < 2) + s->offset[channel][s->nmean - 1] = sum / s->blocksize; + else + s->offset[channel][s->nmean - 1] = (sum / s->blocksize) << s->bitshift; + } - s->cur_chan++; - if (s->cur_chan == s->channels) { - samples = interleave_buffer(samples, s->channels, s->blocksize, s->decoded); - s->cur_chan = 0; - goto frame_done; - } - } - break; - case FN_VERBATIM: - len = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE); - while (len--) { - get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE); - } - break; - case FN_BITSHIFT: - s->bitshift = get_ur_golomb_shorten(&s->gb, BITSHIFTSIZE); - break; - case FN_BLOCKSIZE: { - int blocksize = get_uint(s, av_log2(s->blocksize)); - if (blocksize > s->blocksize) { - av_log(avctx, AV_LOG_ERROR, "Increasing block size is not supported\n"); - return AVERROR_PATCHWELCOME; + /* copy wrap samples for use with next block */ + for (i=-s->nwrap; i<0; i++) + s->decoded[channel][i] = s->decoded[channel][i + s->blocksize]; + + /* shift samples to add in unused zero bits which were removed + during encoding */ + fix_bitshift(s, s->decoded[channel]); + + /* if this is the last channel in the block, output the samples */ + s->cur_chan++; + if (s->cur_chan == s->channels) { + int out_size = s->blocksize * s->channels * + av_get_bytes_per_sample(avctx->sample_fmt); + if (*data_size < out_size) { + av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); + return AVERROR(EINVAL); } - s->blocksize = blocksize; - break; + samples = interleave_buffer(samples, s->channels, s->blocksize, s->decoded); + *data_size = out_size; } - case FN_QUIT: - *data_size = 0; - return buf_size; - default: - av_log(avctx, AV_LOG_ERROR, "unknown shorten function %d\n", cmd); - return -1; } } -frame_done: - *data_size = (int8_t *)samples - (int8_t *)data; + if (s->cur_chan < s->channels) + *data_size = 0; - // s->last_blocksize = s->blocksize; +finish_frame: s->bitindex = get_bits_count(&s->gb) - 8*((get_bits_count(&s->gb))/8); i= (get_bits_count(&s->gb))/8; if (i > buf_size) { @@ -542,5 +624,6 @@ AVCodec ff_shorten_decoder = { .init = shorten_decode_init, .close = shorten_decode_close, .decode = shorten_decode_frame, + .capabilities = CODEC_CAP_DELAY, .long_name= NULL_IF_CONFIG_SMALL("Shorten"), }; diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c index 25053e47e9..d9af5d80cc 100644 --- a/libavcodec/svq1enc.c +++ b/libavcodec/svq1enc.c @@ -461,7 +461,7 @@ static int svq1_encode_plane(SVQ1Context *s, int plane, unsigned char *src_plane s->rd_total += score[best]; for(i=5; i>=0; i--){ - ff_copy_bits(&s->pb, reorder_buffer[best][i], count[best][i]); + avpriv_copy_bits(&s->pb, reorder_buffer[best][i], count[best][i]); } if(best==0){ 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, return -1; } -// align_put_bits(&s->pb); +// avpriv_align_put_bits(&s->pb); while(put_bits_count(&s->pb) & 31) put_bits(&s->pb, 1, 0); diff --git a/libavcodec/utils.c b/libavcodec/utils.c index e920d81118..205e3600c5 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1363,7 +1363,7 @@ int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)) return 0; } -unsigned int ff_toupper4(unsigned int x) +unsigned int avpriv_toupper4(unsigned int x) { return toupper( x &0xFF) + (toupper((x>>8 )&0xFF)<<8 ) diff --git a/libavcodec/vcr1.c b/libavcodec/vcr1.c index 787f4944dd..0c06813cf1 100644 --- a/libavcodec/vcr1.c +++ b/libavcodec/vcr1.c @@ -132,7 +132,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, emms_c(); - align_put_bits(&a->pb); + avpriv_align_put_bits(&a->pb); while(get_bit_count(&a->pb)&31) put_bits(&a->pb, 8, 0); diff --git a/libavcodec/version.h b/libavcodec/version.h index 5fe007b798..0fd5e72874 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -21,7 +21,7 @@ #define AVCODEC_VERSION_H #define LIBAVCODEC_VERSION_MAJOR 53 -#define LIBAVCODEC_VERSION_MINOR 22 +#define LIBAVCODEC_VERSION_MINOR 23 #define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ @@ -98,5 +98,8 @@ #ifndef FF_API_MJPEG_GLOBAL_OPTS #define FF_API_MJPEG_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54) #endif +#ifndef FF_API_GET_ALPHA_INFO +#define FF_API_GET_ALPHA_INFO (LIBAVCODEC_VERSION_MAJOR < 54) +#endif #endif /* AVCODEC_VERSION_H */ diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c index a29481d1b9..59d551e894 100644 --- a/libavcodec/vorbisdec.c +++ b/libavcodec/vorbisdec.c @@ -991,7 +991,7 @@ static av_cold int vorbis_decode_init(AVCodecContext *avccontext) return -1; } - if (ff_split_xiph_headers(headers, headers_len, 30, header_start, header_len) < 0) { + if (avpriv_split_xiph_headers(headers, headers_len, 30, header_start, header_len) < 0) { av_log(avccontext, AV_LOG_ERROR, "Extradata corrupt.\n"); return -1; } diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c index 112dc85c43..82838de61e 100644 --- a/libavcodec/vp3.c +++ b/libavcodec/vp3.c @@ -2276,7 +2276,7 @@ static av_cold int theora_decode_init(AVCodecContext *avctx) return -1; } - if (ff_split_xiph_headers(avctx->extradata, avctx->extradata_size, + if (avpriv_split_xiph_headers(avctx->extradata, avctx->extradata_size, 42, header_start, header_len) < 0) { av_log(avctx, AV_LOG_ERROR, "Corrupt extradata\n"); return -1; diff --git a/libavcodec/wmaenc.c b/libavcodec/wmaenc.c index ae41054f1c..6ec6d7ce57 100644 --- a/libavcodec/wmaenc.c +++ b/libavcodec/wmaenc.c @@ -311,7 +311,7 @@ static int encode_block(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE], put_bits(&s->pb, s->coef_vlcs[tindex]->huffbits[1], s->coef_vlcs[tindex]->huffcodes[1]); } if (s->version == 1 && s->nb_channels >= 2) { - align_put_bits(&s->pb); + avpriv_align_put_bits(&s->pb); } } return 0; @@ -327,7 +327,7 @@ static int encode_frame(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE], return INT_MAX; } - align_put_bits(&s->pb); + avpriv_align_put_bits(&s->pb); return put_bits_count(&s->pb)/8 - s->block_align; } diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c index b87df0906b..119027b7b7 100644 --- a/libavcodec/wmaprodec.c +++ b/libavcodec/wmaprodec.c @@ -1446,14 +1446,14 @@ static void save_bits(WMAProDecodeCtx *s, GetBitContext* gb, int len, s->num_saved_bits += len; if (!append) { - ff_copy_bits(&s->pb, gb->buffer + (get_bits_count(gb) >> 3), + avpriv_copy_bits(&s->pb, gb->buffer + (get_bits_count(gb) >> 3), s->num_saved_bits); } else { int align = 8 - (get_bits_count(gb) & 7); align = FFMIN(align, len); put_bits(&s->pb, align, get_bits(gb, align)); len -= align; - ff_copy_bits(&s->pb, gb->buffer + (get_bits_count(gb) >> 3), len); + avpriv_copy_bits(&s->pb, gb->buffer + (get_bits_count(gb) >> 3), len); } skip_bits_long(gb, len); diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c index 2e3a0f9ba6..b7a6f88a5b 100644 --- a/libavcodec/wmavoice.c +++ b/libavcodec/wmavoice.c @@ -1872,7 +1872,7 @@ static int parse_packet_header(WMAVoiceContext *s) * @param size size of the source data, in bytes * @param gb bit I/O context specifying the current position in the source. * data. This function might use this to align the bit position to - * a whole-byte boundary before calling #ff_copy_bits() on aligned + * a whole-byte boundary before calling #avpriv_copy_bits() on aligned * source data * @param nbits the amount of bits to copy from source to target * @@ -1893,7 +1893,7 @@ static void copy_bits(PutBitContext *pb, rmn_bits &= 7; rmn_bytes >>= 3; if ((rmn_bits = FFMIN(rmn_bits, nbits)) > 0) put_bits(pb, rmn_bits, get_bits(gb, rmn_bits)); - ff_copy_bits(pb, data + size - rmn_bytes, + avpriv_copy_bits(pb, data + size - rmn_bytes, FFMIN(nbits - rmn_bits, rmn_bytes << 3)); } diff --git a/libavcodec/x86/ac3dsp_mmx.c b/libavcodec/x86/ac3dsp_mmx.c index 31275707e9..9578e98d8b 100644 --- a/libavcodec/x86/ac3dsp_mmx.c +++ b/libavcodec/x86/ac3dsp_mmx.c @@ -50,9 +50,9 @@ extern void ff_ac3_extract_exponents_ssse3(uint8_t *exp, int32_t *coef, int nb_c av_cold void ff_ac3dsp_init_x86(AC3DSPContext *c, int bit_exact) { +#if HAVE_YASM int mm_flags = av_get_cpu_flags(); -#if HAVE_YASM if (mm_flags & AV_CPU_FLAG_MMX) { c->ac3_exponent_min = ff_ac3_exponent_min_mmx; c->ac3_max_msb_abs_int16 = ff_ac3_max_msb_abs_int16_mmx; diff --git a/libavcodec/x86/h264_intrapred_init.c b/libavcodec/x86/h264_intrapred_init.c index cdf7d55d96..540ec87ad3 100644 --- a/libavcodec/x86/h264_intrapred_init.c +++ b/libavcodec/x86/h264_intrapred_init.c @@ -169,9 +169,9 @@ void ff_pred4x4_vertical_vp8_mmxext(uint8_t *src, const uint8_t *topright, int s void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc) { +#if HAVE_YASM int mm_flags = av_get_cpu_flags(); -#if HAVE_YASM if (bit_depth == 8) { if (mm_flags & AV_CPU_FLAG_MMX) { h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vertical_mmx; diff --git a/libavcodec/x86/proresdsp-init.c b/libavcodec/x86/proresdsp-init.c index 6263beac34..c4aeb7f503 100644 --- a/libavcodec/x86/proresdsp-init.c +++ b/libavcodec/x86/proresdsp-init.c @@ -52,6 +52,6 @@ void ff_proresdsp_x86_init(ProresDSPContext *dsp, AVCodecContext *avctx) dsp->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM; dsp->idct_put = ff_prores_idct_put_10_avx; } -#endif -#endif +#endif /* HAVE_AVX */ +#endif /* ARCH_X86_64 && HAVE_YASM */ } diff --git a/libavcodec/x86/vp8dsp-init.c b/libavcodec/x86/vp8dsp-init.c index 201b34e243..a75fdf5bc5 100644 --- a/libavcodec/x86/vp8dsp-init.c +++ b/libavcodec/x86/vp8dsp-init.c @@ -283,9 +283,9 @@ DECLARE_LOOP_FILTER(sse4) av_cold void ff_vp8dsp_init_x86(VP8DSPContext* c) { +#if HAVE_YASM int mm_flags = av_get_cpu_flags(); -#if HAVE_YASM if (mm_flags & AV_CPU_FLAG_MMX) { c->vp8_idct_dc_add = ff_vp8_idct_dc_add_mmx; c->vp8_idct_dc_add4y = ff_vp8_idct_dc_add4y_mmx; diff --git a/libavcodec/xiph.c b/libavcodec/xiph.c index 2f4f25c929..0636f8ef59 100644 --- a/libavcodec/xiph.c +++ b/libavcodec/xiph.c @@ -21,7 +21,7 @@ #include "libavutil/intreadwrite.h" #include "xiph.h" -int ff_split_xiph_headers(uint8_t *extradata, int extradata_size, +int avpriv_split_xiph_headers(uint8_t *extradata, int extradata_size, int first_header_size, uint8_t *header_start[3], int header_len[3]) { diff --git a/libavcodec/xiph.h b/libavcodec/xiph.h index 0cbb870355..cd8caa4810 100644 --- a/libavcodec/xiph.h +++ b/libavcodec/xiph.h @@ -36,8 +36,8 @@ * @param[out] header_len The sizes of each of the three headers. * @return On error a negative value is returned, on success zero. */ -int ff_split_xiph_headers(uint8_t *extradata, int extradata_size, - int first_header_size, uint8_t *header_start[3], - int header_len[3]); +int avpriv_split_xiph_headers(uint8_t *extradata, int extradata_size, + int first_header_size, uint8_t *header_start[3], + int header_len[3]); #endif /* AVCODEC_XIPH_H */ diff --git a/libavcodec/xsubenc.c b/libavcodec/xsubenc.c index 447759b1fe..4245f45bac 100644 --- a/libavcodec/xsubenc.c +++ b/libavcodec/xsubenc.c @@ -90,7 +90,7 @@ static int xsub_encode_rle(PutBitContext *pb, const uint8_t *bitmap, if (color != PADDING_COLOR && (PADDING + (w&1))) put_xsub_rle(pb, PADDING + (w&1), PADDING_COLOR); - align_put_bits(pb); + avpriv_align_put_bits(pb); bitmap += linesize; } @@ -194,7 +194,7 @@ static int xsub_encode(AVCodecContext *avctx, unsigned char *buf, // Enforce total height to be be multiple of 2 if (h->rects[0]->h & 1) { put_xsub_rle(&pb, h->rects[0]->w, PADDING_COLOR); - align_put_bits(&pb); + avpriv_align_put_bits(&pb); } flush_put_bits(&pb); diff --git a/libavdevice/dv1394.c b/libavdevice/dv1394.c index 951445f813..44d401a99f 100644 --- a/libavdevice/dv1394.c +++ b/libavdevice/dv1394.c @@ -86,7 +86,7 @@ static int dv1394_read_header(AVFormatContext * context, AVFormatParameters * ap { struct dv1394_data *dv = context->priv_data; - dv->dv_demux = dv_init_demux(context); + dv->dv_demux = avpriv_dv_init_demux(context); if (!dv->dv_demux) goto failed; @@ -124,7 +124,7 @@ static int dv1394_read_packet(AVFormatContext *context, AVPacket *pkt) struct dv1394_data *dv = context->priv_data; int size; - size = dv_get_packet(dv->dv_demux, pkt); + size = avpriv_dv_get_packet(dv->dv_demux, pkt); if (size > 0) return size; @@ -186,7 +186,7 @@ restart_poll: av_dlog(context, "index %d, avail %d, done %d\n", dv->index, dv->avail, dv->done); - size = dv_produce_packet(dv->dv_demux, pkt, + size = avpriv_dv_produce_packet(dv->dv_demux, pkt, dv->ring + (dv->index * DV1394_PAL_FRAME_SIZE), DV1394_PAL_FRAME_SIZE, -1); dv->index = (dv->index + 1) % DV1394_RING_FRAMES; diff --git a/libavdevice/libcdio.c b/libavdevice/libcdio.c index d7584fc3fc..dbd593dde5 100644 --- a/libavdevice/libcdio.c +++ b/libavdevice/libcdio.c @@ -98,7 +98,7 @@ static av_cold int read_header(AVFormatContext *ctx, AVFormatParameters *ap) for (i = 0; i < s->drive->tracks; i++) { char title[16]; snprintf(title, sizeof(title), "track %02d", s->drive->disc_toc[i].bTrack); - ff_new_chapter(ctx, i, st->time_base, s->drive->disc_toc[i].dwStartSector, + avpriv_new_chapter(ctx, i, st->time_base, s->drive->disc_toc[i].dwStartSector, s->drive->disc_toc[i+1].dwStartSector, title); } diff --git a/libavformat/ac3dec.c b/libavformat/ac3dec.c index 5d4d2f64c5..54d4fd2626 100644 --- a/libavformat/ac3dec.c +++ b/libavformat/ac3dec.c @@ -41,7 +41,7 @@ static int ac3_eac3_probe(AVProbeData *p, enum CodecID expected_codec_id) for(frames = 0; buf2 < end; frames++) { init_get_bits(&gbc, buf2, 54); - if(ff_ac3_parse_header(&gbc, &hdr) < 0) + if(avpriv_ac3_parse_header(&gbc, &hdr) < 0) break; if(buf2 + hdr.frame_size > end || av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, buf2 + 2, hdr.frame_size - 2)) diff --git a/libavformat/adtsenc.c b/libavformat/adtsenc.c index 5387cc855b..4b14b95ef4 100644 --- a/libavformat/adtsenc.c +++ b/libavformat/adtsenc.c @@ -35,7 +35,7 @@ int ff_adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, uint8_t *buf int off; init_get_bits(&gb, buf, size * 8); - off = ff_mpeg4audio_get_config(&m4ac, buf, size); + off = avpriv_mpeg4audio_get_config(&m4ac, buf, size); if (off < 0) return off; skip_bits_long(&gb, off); @@ -67,7 +67,7 @@ int ff_adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, uint8_t *buf init_put_bits(&pb, adts->pce_data, MAX_PCE_SIZE); put_bits(&pb, 3, 5); //ID_PCE - adts->pce_size = (ff_copy_pce_data(&pb, &gb) + 3) / 8; + adts->pce_size = (avpriv_copy_pce_data(&pb, &gb) + 3) / 8; flush_put_bits(&pb); } diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index e2acd13470..6af4439e87 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -569,7 +569,7 @@ static int asf_read_marker(AVFormatContext *s, int64_t size) name_len = avio_rl32(pb); // name length if ((ret = avio_get_str16le(pb, name_len * 2, name, sizeof(name))) < name_len) avio_skip(pb, name_len - ret); - ff_new_chapter(s, i, (AVRational){1, 10000000}, pres_time, AV_NOPTS_VALUE, name ); + avpriv_new_chapter(s, i, (AVRational){1, 10000000}, pres_time, AV_NOPTS_VALUE, name ); } return 0; diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 2895d89896..0995150454 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -490,7 +490,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) av_freep(&s->streams[0]); s->nb_streams = 0; if (CONFIG_DV_DEMUXER) { - avi->dv_demux = dv_init_demux(s); + avi->dv_demux = avpriv_dv_init_demux(s); if (!avi->dv_demux) goto fail; } @@ -1012,7 +1012,7 @@ static int avi_read_packet(AVFormatContext *s, AVPacket *pkt) void* dstr; if (CONFIG_DV_DEMUXER && avi->dv_demux) { - int size = dv_get_packet(avi->dv_demux, pkt); + int size = avpriv_dv_get_packet(avi->dv_demux, pkt); if (size >= 0) return size; } @@ -1115,7 +1115,7 @@ resync: if (CONFIG_DV_DEMUXER && avi->dv_demux) { dstr = pkt->destruct; - size = dv_produce_packet(avi->dv_demux, pkt, + size = avpriv_dv_produce_packet(avi->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); pkt->destruct = dstr; pkt->flags |= AV_PKT_FLAG_KEY; diff --git a/libavformat/dv.c b/libavformat/dv.c index f0f007aa53..378f29f0f3 100644 --- a/libavformat/dv.c +++ b/libavformat/dv.c @@ -270,7 +270,7 @@ static int dv_extract_video_info(DVDemuxContext *c, uint8_t* frame) * The following 3 functions constitute our interface to the world */ -DVDemuxContext* dv_init_demux(AVFormatContext *s) +DVDemuxContext* avpriv_dv_init_demux(AVFormatContext *s) { DVDemuxContext *c; @@ -299,7 +299,7 @@ DVDemuxContext* dv_init_demux(AVFormatContext *s) return c; } -int dv_get_packet(DVDemuxContext *c, AVPacket *pkt) +int avpriv_dv_get_packet(DVDemuxContext *c, AVPacket *pkt) { int size = -1; int i; @@ -316,14 +316,14 @@ int dv_get_packet(DVDemuxContext *c, AVPacket *pkt) return size; } -int dv_produce_packet(DVDemuxContext *c, AVPacket *pkt, +int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt, uint8_t* buf, int buf_size, int64_t pos) { int size, i; uint8_t *ppcm[4] = {0}; if (buf_size < DV_PROFILE_BYTES || - !(c->sys = ff_dv_frame_profile(c->sys, buf, buf_size)) || + !(c->sys = avpriv_dv_frame_profile(c->sys, buf, buf_size)) || buf_size < c->sys->frame_size) { return -1; /* Broken frame, or not enough data */ } @@ -371,7 +371,7 @@ static int64_t dv_frame_offset(AVFormatContext *s, DVDemuxContext *c, int64_t timestamp, int flags) { // FIXME: sys may be wrong if last dv_read_packet() failed (buffer is junk) - const DVprofile* sys = ff_dv_codec_profile(c->vst->codec); + const DVprofile* sys = avpriv_dv_codec_profile(c->vst->codec); int64_t offset; int64_t size = avio_size(s->pb) - s->data_offset; int64_t max_offset = ((size-1) / sys->frame_size) * sys->frame_size; @@ -409,7 +409,7 @@ static int dv_read_header(AVFormatContext *s, unsigned state, marker_pos = 0; RawDVContext *c = s->priv_data; - c->dv_demux = dv_init_demux(s); + c->dv_demux = avpriv_dv_init_demux(s); if (!c->dv_demux) return -1; @@ -434,7 +434,7 @@ static int dv_read_header(AVFormatContext *s, avio_seek(s->pb, -DV_PROFILE_BYTES, SEEK_CUR) < 0) return AVERROR(EIO); - c->dv_demux->sys = ff_dv_frame_profile(c->dv_demux->sys, c->buf, DV_PROFILE_BYTES); + c->dv_demux->sys = avpriv_dv_frame_profile(c->dv_demux->sys, c->buf, DV_PROFILE_BYTES); if (!c->dv_demux->sys) { av_log(s, AV_LOG_ERROR, "Can't determine profile of DV input stream.\n"); return -1; @@ -452,7 +452,7 @@ static int dv_read_packet(AVFormatContext *s, AVPacket *pkt) int size; RawDVContext *c = s->priv_data; - size = dv_get_packet(c->dv_demux, pkt); + size = avpriv_dv_get_packet(c->dv_demux, pkt); if (size < 0) { int64_t pos = avio_tell(s->pb); @@ -462,7 +462,7 @@ static int dv_read_packet(AVFormatContext *s, AVPacket *pkt) if (avio_read(s->pb, c->buf, size) <= 0) return AVERROR(EIO); - size = dv_produce_packet(c->dv_demux, pkt, c->buf, size, pos); + size = avpriv_dv_produce_packet(c->dv_demux, pkt, c->buf, size, pos); } return size; diff --git a/libavformat/dv.h b/libavformat/dv.h index ce240c072c..722067f206 100644 --- a/libavformat/dv.h +++ b/libavformat/dv.h @@ -31,9 +31,9 @@ #include "avformat.h" typedef struct DVDemuxContext DVDemuxContext; -DVDemuxContext* dv_init_demux(AVFormatContext* s); -int dv_get_packet(DVDemuxContext*, AVPacket *); -int dv_produce_packet(DVDemuxContext*, AVPacket*, uint8_t*, int, int64_t); +DVDemuxContext* avpriv_dv_init_demux(AVFormatContext* s); +int avpriv_dv_get_packet(DVDemuxContext*, AVPacket *); +int avpriv_dv_produce_packet(DVDemuxContext*, AVPacket*, uint8_t*, int, int64_t); void dv_offset_reset(DVDemuxContext *c, int64_t frame_offset); typedef struct DVMuxContext DVMuxContext; diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c index ae348297b4..ce6568b5eb 100644 --- a/libavformat/dvenc.c +++ b/libavformat/dvenc.c @@ -320,7 +320,7 @@ static DVMuxContext* dv_init_mux(AVFormatContext* s) c->ast[i]->codec->channels != 2)) goto bail_out; } - c->sys = ff_dv_codec_profile(vst->codec); + c->sys = avpriv_dv_codec_profile(vst->codec); if (!c->sys) goto bail_out; diff --git a/libavformat/ffmetadec.c b/libavformat/ffmetadec.c index da4dc04056..1d223fb9e0 100644 --- a/libavformat/ffmetadec.c +++ b/libavformat/ffmetadec.c @@ -75,7 +75,7 @@ static AVChapter *read_chapter(AVFormatContext *s) end = AV_NOPTS_VALUE; } - return ff_new_chapter(s, s->nb_chapters, tb, start, end, NULL); + return avpriv_new_chapter(s, s->nb_chapters, tb, start, end, NULL); } static uint8_t *unescape(uint8_t *buf, int size) diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c index 7540d33e32..a5a32131a7 100644 --- a/libavformat/flacdec.c +++ b/libavformat/flacdec.c @@ -48,7 +48,7 @@ static int flac_read_header(AVFormatContext *s, /* process metadata blocks */ while (!url_feof(s->pb) && !metadata_last) { avio_read(s->pb, header, 4); - ff_flac_parse_block_header(header, &metadata_last, &metadata_type, + avpriv_flac_parse_block_header(header, &metadata_last, &metadata_type, &metadata_size); switch (metadata_type) { /* allocate and read metadata block for supported types */ @@ -87,7 +87,7 @@ static int flac_read_header(AVFormatContext *s, buffer = NULL; /* get codec params from STREAMINFO header */ - ff_flac_parse_streaminfo(st->codec, &si, st->codec->extradata); + avpriv_flac_parse_streaminfo(st->codec, &si, st->codec->extradata); /* set time base and duration */ if (si.samplerate > 0) { diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c index 617b8f849e..e7bbb783ab 100644 --- a/libavformat/flacenc.c +++ b/libavformat/flacenc.c @@ -94,7 +94,7 @@ static int flac_write_trailer(struct AVFormatContext *s) enum FLACExtradataFormat format; int64_t file_size; - if (!ff_flac_is_extradata_valid(s->streams[0]->codec, &format, &streaminfo)) + if (!avpriv_flac_is_extradata_valid(s->streams[0]->codec, &format, &streaminfo)) return -1; if (pb->seekable) { diff --git a/libavformat/flacenc_header.c b/libavformat/flacenc_header.c index 389efbd01a..cfbdc890af 100644 --- a/libavformat/flacenc_header.c +++ b/libavformat/flacenc_header.c @@ -34,7 +34,7 @@ int ff_flac_write_header(AVIOContext *pb, AVCodecContext *codec, enum FLACExtradataFormat format; header[4] = last_block ? 0x80 : 0x00; - if (!ff_flac_is_extradata_valid(codec, &format, &streaminfo)) + if (!avpriv_flac_is_extradata_valid(codec, &format, &streaminfo)) return -1; /* write "fLaC" stream marker and first metadata block header if needed */ diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 9791a1924d..7025ddd014 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -542,7 +542,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) return ret; if (st->codec->codec_id == CODEC_ID_AAC) { MPEG4AudioConfig cfg; - ff_mpeg4audio_get_config(&cfg, st->codec->extradata, + avpriv_mpeg4audio_get_config(&cfg, st->codec->extradata, st->codec->extradata_size); st->codec->channels = cfg.channels; if (cfg.ext_sample_rate) diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c index 143c58ca50..98c4170311 100644 --- a/libavformat/flvenc.c +++ b/libavformat/flvenc.c @@ -61,7 +61,7 @@ typedef struct FLVContext { int64_t filesize_offset; int64_t duration; int delay; ///< first dts delay for AVC - int64_t last_video_ts; + int64_t last_ts; } FLVContext; static int get_audio_flags(AVCodecContext *enc){ @@ -78,11 +78,6 @@ static int get_audio_flags(AVCodecContext *enc){ av_log(enc, AV_LOG_ERROR, "flv only supports mono Speex audio\n"); return -1; } - if (enc->frame_size / 320 > 8) { - av_log(enc, AV_LOG_WARNING, "Warning: Speex stream has more than " - "8 frames per packet. Adobe Flash " - "Player cannot handle this!\n"); - } return FLV_CODECID_SPEEX | FLV_SAMPLERATE_11025HZ | FLV_SAMPLESSIZE_16BIT; } else { switch (enc->sample_rate) { @@ -223,7 +218,7 @@ static int flv_write_header(AVFormatContext *s) } } - flv->last_video_ts = -1; + flv->last_ts = -1; /* write meta_tag */ avio_w8(pb, 18); // tag type META @@ -368,7 +363,7 @@ static int flv_write_trailer(AVFormatContext *s) AVCodecContext *enc = s->streams[i]->codec; if (enc->codec_type == AVMEDIA_TYPE_VIDEO && (enc->codec_id == CODEC_ID_H264 || enc->codec_id == CODEC_ID_MPEG4)) { - put_avc_eos_tag(pb, flv->last_video_ts); + put_avc_eos_tag(pb, flv->last_ts); } } @@ -434,19 +429,26 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) if (ff_avc_parse_nal_units_buf(pkt->data, &data, &size) < 0) return -1; } - if (!flv->delay && pkt->dts < 0) - flv->delay = -pkt->dts; } else if (enc->codec_id == CODEC_ID_AAC && pkt->size > 2 && (AV_RB16(pkt->data) & 0xfff0) == 0xfff0) { av_log(s, AV_LOG_ERROR, "malformated aac bitstream, use -absf aac_adtstoasc\n"); return -1; } + if (!flv->delay && pkt->dts < 0) + flv->delay = -pkt->dts; ts = pkt->dts + flv->delay; // add delay to force positive dts - if (enc->codec_type == AVMEDIA_TYPE_VIDEO) { - if (flv->last_video_ts < ts) - flv->last_video_ts = ts; + + /* check Speex packet duration */ + if (enc->codec_id == CODEC_ID_SPEEX && ts - flv->last_ts > 160) { + av_log(s, AV_LOG_WARNING, "Warning: Speex stream has more than " + "8 frames per packet. Adobe Flash " + "Player cannot handle this!\n"); } + + if (flv->last_ts < ts) + flv->last_ts = ts; + avio_wb24(pb,size + flags_size); avio_wb24(pb,ts); avio_w8(pb,(ts >> 24) & 0x7F); // timestamps are 32bits _signed_ diff --git a/libavformat/gxf.c b/libavformat/gxf.c index df99310150..d42c3fd307 100644 --- a/libavformat/gxf.c +++ b/libavformat/gxf.c @@ -185,9 +185,9 @@ static void gxf_material_tags(AVIOContext *pb, int *len, struct gxf_stream_info * @return fps as AVRational, or 0 / 0 if unknown */ static AVRational fps_tag2avr(int32_t fps) { - extern const AVRational ff_frame_rate_tab[]; + extern const AVRational avpriv_frame_rate_tab[]; if (fps < 1 || fps > 9) fps = 9; - return ff_frame_rate_tab[9 - fps]; // values have opposite order + return avpriv_frame_rate_tab[9 - fps]; // values have opposite order } /** diff --git a/libavformat/internal.h b/libavformat/internal.h index 72f15d3362..a2e80f2de3 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -223,8 +223,8 @@ int ff_add_index_entry(AVIndexEntry **index_entries, * * @return AVChapter or NULL on error */ -AVChapter *ff_new_chapter(AVFormatContext *s, int id, AVRational time_base, - int64_t start, int64_t end, const char *title); +AVChapter *avpriv_new_chapter(AVFormatContext *s, int id, AVRational time_base, + int64_t start, int64_t end, const char *title); /** * Ensure the index uses less memory than the maximum specified in diff --git a/libavformat/isom.c b/libavformat/isom.c index ea20c3c773..782b1396f3 100644 --- a/libavformat/isom.c +++ b/libavformat/isom.c @@ -433,11 +433,11 @@ int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext st->codec->extradata_size = len; if (st->codec->codec_id == CODEC_ID_AAC) { MPEG4AudioConfig cfg; - ff_mpeg4audio_get_config(&cfg, st->codec->extradata, + avpriv_mpeg4audio_get_config(&cfg, st->codec->extradata, st->codec->extradata_size); st->codec->channels = cfg.channels; if (cfg.object_type == 29 && cfg.sampling_index < 3) // old mp3on4 - st->codec->sample_rate = ff_mpa_freq_tab[cfg.sampling_index]; + st->codec->sample_rate = avpriv_mpa_freq_tab[cfg.sampling_index]; else if (cfg.ext_sample_rate) st->codec->sample_rate = cfg.ext_sample_rate; else diff --git a/libavformat/latmenc.c b/libavformat/latmenc.c index 9ff2f4f86f..56522106d6 100644 --- a/libavformat/latmenc.c +++ b/libavformat/latmenc.c @@ -55,7 +55,7 @@ static int latm_decode_extradata(LATMContext *ctx, uint8_t *buf, int size) MPEG4AudioConfig m4ac; init_get_bits(&gb, buf, size * 8); - ctx->off = ff_mpeg4audio_get_config(&m4ac, buf, size); + ctx->off = avpriv_mpeg4audio_get_config(&m4ac, buf, size); if (ctx->off < 0) return ctx->off; skip_bits_long(&gb, ctx->off); @@ -110,12 +110,12 @@ static int latm_write_frame_header(AVFormatContext *s, PutBitContext *bs) /* AudioSpecificConfig */ if (ctx->object_type == AOT_ALS) { header_size = avctx->extradata_size-(ctx->off + 7) >> 3; - ff_copy_bits(bs, &avctx->extradata[ctx->off], header_size); + avpriv_copy_bits(bs, &avctx->extradata[ctx->off], header_size); } else { - ff_copy_bits(bs, avctx->extradata, ctx->off + 3); + avpriv_copy_bits(bs, avctx->extradata, ctx->off + 3); if (!ctx->channel_conf) { - ff_copy_pce_data(bs, &gb); + avpriv_copy_pce_data(bs, &gb); } } @@ -168,7 +168,7 @@ static int latm_write_packet(AVFormatContext *s, AVPacket *pkt) for (i = 0; i < pkt->size; i++) put_bits(&bs, 8, pkt->data[i]); - align_put_bits(&bs); + avpriv_align_put_bits(&bs); flush_put_bits(&bs); len = put_bits_count(&bs) >> 3; diff --git a/libavformat/libavformat.v b/libavformat/libavformat.v index 0ec1c3c4de..2a49539f0a 100644 --- a/libavformat/libavformat.v +++ b/libavformat/libavformat.v @@ -1,7 +1,23 @@ LIBAVFORMAT_$MAJOR { - global: *; - local: - ff_*_demuxer; - ff_*_muxer; - ff_*_protocol; + global: av*; + #FIXME those are for avserver + ff_inet_aton; + ff_socket_nonblock; + ffm_set_write_index; + ffm_read_write_index; + ffm_write_write_index; + ff_rtsp_parse_line; + ff_rtp_get_local_rtp_port; + ff_rtp_get_local_rtcp_port; + ffio_open_dyn_packet_buf; + url_open; + url_close; + url_write; + url_get_max_packet_size; + #those are deprecated, remove on next bump + find_info_tag; + parse_date; + dump_format; + url_*; + local: *; }; diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 207c749b82..78e337bfab 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1303,8 +1303,8 @@ static int matroska_aac_sri(int samplerate) { int sri; - for (sri=0; sri<FF_ARRAY_ELEMS(ff_mpeg4audio_sample_rates); sri++) - if (ff_mpeg4audio_sample_rates[sri] == samplerate) + for (sri=0; sri<FF_ARRAY_ELEMS(avpriv_mpeg4audio_sample_rates); sri++) + if (avpriv_mpeg4audio_sample_rates[sri] == samplerate) break; return sri; } @@ -1668,7 +1668,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap) if (chapters[i].start != AV_NOPTS_VALUE && chapters[i].uid && (max_start==0 || chapters[i].start > max_start)) { chapters[i].chapter = - ff_new_chapter(s, chapters[i].uid, (AVRational){1, 1000000000}, + avpriv_new_chapter(s, chapters[i].uid, (AVRational){1, 1000000000}, chapters[i].start, chapters[i].end, chapters[i].title); av_dict_set(&chapters[i].chapter->metadata, diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index da3b6db5fe..6cf4156cb8 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -423,7 +423,7 @@ static int put_xiph_codecpriv(AVFormatContext *s, AVIOContext *pb, AVCodecContex else first_header_size = 42; - if (ff_split_xiph_headers(codec->extradata, codec->extradata_size, + if (avpriv_split_xiph_headers(codec->extradata, codec->extradata_size, first_header_size, header_start, header_len) < 0) { av_log(s, AV_LOG_ERROR, "Extradata corrupt.\n"); return -1; @@ -443,7 +443,7 @@ static void get_aac_sample_rates(AVFormatContext *s, AVCodecContext *codec, int { MPEG4AudioConfig mp4ac; - if (ff_mpeg4audio_get_config(&mp4ac, codec->extradata, codec->extradata_size) < 0) { + if (avpriv_mpeg4audio_get_config(&mp4ac, codec->extradata, codec->extradata_size) < 0) { av_log(s, AV_LOG_WARNING, "Error parsing AAC extradata, unable to determine samplerate.\n"); return; } diff --git a/libavformat/mov.c b/libavformat/mov.c index fb6003319a..3c8bbc9ca1 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -289,7 +289,7 @@ static int mov_read_chpl(MOVContext *c, AVIOContext *pb, MOVAtom atom) avio_read(pb, str, str_len); str[str_len] = 0; - ff_new_chapter(c->fc, i, (AVRational){1,10000000}, start, AV_NOPTS_VALUE, str); + avpriv_new_chapter(c->fc, i, (AVRational){1,10000000}, start, AV_NOPTS_VALUE, str); } return 0; } @@ -1291,7 +1291,7 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries) #if CONFIG_DV_DEMUXER case CODEC_ID_DVAUDIO: c->dv_fctx = avformat_alloc_context(); - c->dv_demux = dv_init_demux(c->dv_fctx); + c->dv_demux = avpriv_dv_init_demux(c->dv_fctx); if (!c->dv_demux) { av_log(c->fc, AV_LOG_ERROR, "dv demux context init error\n"); return -1; @@ -2484,7 +2484,7 @@ static void mov_read_chapters(AVFormatContext *s) } } - ff_new_chapter(s, i, st->time_base, sample->timestamp, end, title); + avpriv_new_chapter(s, i, st->time_base, sample->timestamp, end, title); av_freep(&title); } finish: @@ -2592,10 +2592,10 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) } #if CONFIG_DV_DEMUXER if (mov->dv_demux && sc->dv_audio_container) { - dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); + avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); av_free(pkt->data); pkt->size = 0; - ret = dv_get_packet(mov->dv_demux, pkt); + ret = avpriv_dv_get_packet(mov->dv_demux, pkt); if (ret < 0) return ret; } diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c index 1210087b70..3101bae99d 100644 --- a/libavformat/mp3dec.c +++ b/libavformat/mp3dec.c @@ -51,7 +51,7 @@ static int mp3_read_probe(AVProbeData *p) for(frames = 0; buf2 < end; frames++) { header = AV_RB32(buf2); - fsize = ff_mpa_decode_header(&avctx, header, &sample_rate, &sample_rate, &sample_rate, &sample_rate); + fsize = avpriv_mpa_decode_header(&avctx, header, &sample_rate, &sample_rate, &sample_rate, &sample_rate); if(fsize < 0) break; buf2 += fsize; @@ -86,7 +86,7 @@ static int mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, int64_t base) if(ff_mpa_check_header(v) < 0) return -1; - if (ff_mpegaudio_decode_header(&c, v) == 0) + if (avpriv_mpegaudio_decode_header(&c, v) == 0) vbrtag_size = c.frame_size; if(c.layer != 3) return -1; diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c index b212978dc9..b847350232 100644 --- a/libavformat/mp3enc.c +++ b/libavformat/mp3enc.c @@ -235,12 +235,12 @@ static int mp3_write_xing(AVFormatContext *s) int srate_idx, i, channels; int needed; - for (i = 0; i < FF_ARRAY_ELEMS(ff_mpa_freq_tab); i++) - if (ff_mpa_freq_tab[i] == codec->sample_rate) { + for (i = 0; i < FF_ARRAY_ELEMS(avpriv_mpa_freq_tab); i++) + if (avpriv_mpa_freq_tab[i] == codec->sample_rate) { srate_idx = i; break; } - if (i == FF_ARRAY_ELEMS(ff_mpa_freq_tab)) { + if (i == FF_ARRAY_ELEMS(avpriv_mpa_freq_tab)) { av_log(s, AV_LOG_ERROR, "Unsupported sample rate.\n"); return -1; } @@ -263,7 +263,7 @@ static int mp3_write_xing(AVFormatContext *s) mask = (bitrate_idx << 4) << 8; header |= mask; - ff_mpegaudio_decode_header(&c, header); + avpriv_mpegaudio_decode_header(&c, header); xing_offset=xing_offtbl[c.lsf == 1][c.nb_channels == 1]; needed = 4 // header + xing_offset diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index cf636fe99e..fa773ebbee 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -979,7 +979,7 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt) } do { - p = ff_find_start_code(p, buf_end, &state); + p = avpriv_mpv_find_start_code(p, buf_end, &state); //av_log(s, AV_LOG_INFO, "nal %d\n", state & 0x1f); } while (p < buf_end && (state & 0x1f) != 9 && (state & 0x1f) != 5 && (state & 0x1f) != 1); diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index c48f503fbd..6015bf6900 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -416,7 +416,7 @@ static int decode_info_header(NUTContext *nut){ if(chapter_id && !stream_id_plus1){ int64_t start= chapter_start / nut->time_base_count; - chapter= ff_new_chapter(s, chapter_id, + chapter= avpriv_new_chapter(s, chapter_id, nut->time_base[chapter_start % nut->time_base_count], start, start + chapter_len, NULL); metadata = &chapter->metadata; diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c index d25a7975db..3c963debd6 100644 --- a/libavformat/nutenc.c +++ b/libavformat/nutenc.c @@ -59,10 +59,10 @@ static int find_expected_header(AVCodecContext *c, int size, int key_frame, uint else if(sample_rate < (44100 + 48000)/2) sample_rate_index=0; else sample_rate_index=1; - sample_rate= ff_mpa_freq_tab[sample_rate_index] >> (lsf + mpeg25); + sample_rate= avpriv_mpa_freq_tab[sample_rate_index] >> (lsf + mpeg25); for(bitrate_index=2; bitrate_index<30; bitrate_index++){ - frame_size = ff_mpa_bitrate_tab[lsf][layer-1][bitrate_index>>1]; + frame_size = avpriv_mpa_bitrate_tab[lsf][layer-1][bitrate_index>>1]; frame_size = (frame_size * 144000) / (sample_rate << lsf) + (bitrate_index&1); if(frame_size == size) diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c index 67dbc04205..53350719fa 100644 --- a/libavformat/oggenc.c +++ b/libavformat/oggenc.c @@ -274,7 +274,7 @@ static int ogg_build_flac_headers(AVCodecContext *avctx, uint8_t *streaminfo; uint8_t *p; - if (!ff_flac_is_extradata_valid(avctx, &format, &streaminfo)) + if (!avpriv_flac_is_extradata_valid(avctx, &format, &streaminfo)) return -1; // first packet: STREAMINFO @@ -397,7 +397,7 @@ static int ogg_write_header(AVFormatContext *s) int header_type = st->codec->codec_id == CODEC_ID_VORBIS ? 3 : 0x81; int framing_bit = st->codec->codec_id == CODEC_ID_VORBIS ? 1 : 0; - if (ff_split_xiph_headers(st->codec->extradata, st->codec->extradata_size, + if (avpriv_split_xiph_headers(st->codec->extradata, st->codec->extradata_size, st->codec->codec_id == CODEC_ID_VORBIS ? 30 : 42, oggstream->header, oggstream->header_len) < 0) { av_log(s, AV_LOG_ERROR, "Extradata corrupted\n"); diff --git a/libavformat/oggparsedirac.c b/libavformat/oggparsedirac.c index b8ce4fe291..524736a416 100644 --- a/libavformat/oggparsedirac.c +++ b/libavformat/oggparsedirac.c @@ -36,7 +36,7 @@ static int dirac_header(AVFormatContext *s, int idx) return 0; init_get_bits(&gb, os->buf + os->pstart + 13, (os->psize - 13) * 8); - if (ff_dirac_parse_sequence_header(st->codec, &gb, &source) < 0) + if (avpriv_dirac_parse_sequence_header(st->codec, &gb, &source) < 0) return -1; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; diff --git a/libavformat/oggparseflac.c b/libavformat/oggparseflac.c index a51a85545c..87239c6a53 100644 --- a/libavformat/oggparseflac.c +++ b/libavformat/oggparseflac.c @@ -55,7 +55,7 @@ flac_header (AVFormatContext * s, int idx) if (get_bits_long(&gb, 32) != FLAC_STREAMINFO_SIZE) return -1; - ff_flac_parse_streaminfo(st->codec, &si, streaminfo_start); + avpriv_flac_parse_streaminfo(st->codec, &si, streaminfo_start); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = CODEC_ID_FLAC; diff --git a/libavformat/oggparsespeex.c b/libavformat/oggparsespeex.c index 80b2001ddf..bbeeb20d60 100644 --- a/libavformat/oggparsespeex.c +++ b/libavformat/oggparsespeex.c @@ -31,6 +31,7 @@ #include "oggdec.h" struct speex_params { + int packet_size; int final_packet_duration; int seq; }; @@ -58,14 +59,10 @@ static int speex_header(AVFormatContext *s, int idx) { st->codec->sample_rate = AV_RL32(p + 36); st->codec->channels = AV_RL32(p + 48); - /* We treat the whole Speex packet as a single frame everywhere Speex - is handled in FFmpeg. This avoids the complexities of splitting - and joining individual Speex frames, which are not always - byte-aligned. */ - st->codec->frame_size = AV_RL32(p + 56); - frames_per_packet = AV_RL32(p + 64); + spxp->packet_size = AV_RL32(p + 56); + frames_per_packet = AV_RL32(p + 64); if (frames_per_packet) - st->codec->frame_size *= frames_per_packet; + spxp->packet_size *= frames_per_packet; st->codec->extradata_size = os->psize; st->codec->extradata = av_malloc(st->codec->extradata_size @@ -95,7 +92,7 @@ static int speex_packet(AVFormatContext *s, int idx) struct ogg *ogg = s->priv_data; struct ogg_stream *os = ogg->streams + idx; struct speex_params *spxp = os->private; - int packet_size = s->streams[idx]->codec->frame_size; + int packet_size = spxp->packet_size; if (os->flags & OGG_FLAG_EOS && os->lastpts != AV_NOPTS_VALUE && os->granule > 0) { @@ -108,9 +105,10 @@ static int speex_packet(AVFormatContext *s, int idx) if (!os->lastpts && os->granule > 0) /* first packet */ - os->pduration = os->granule - packet_size * (ogg_page_packets(os) - 1); - else if (os->flags & OGG_FLAG_EOS && os->segp == os->nsegs && - spxp->final_packet_duration) + os->lastpts = os->lastdts = os->granule - packet_size * + ogg_page_packets(os); + if (os->flags & OGG_FLAG_EOS && os->segp == os->nsegs && + spxp->final_packet_duration) /* final packet */ os->pduration = spxp->final_packet_duration; else diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c index 86951f3e2f..8a406976b5 100644 --- a/libavformat/oggparsevorbis.c +++ b/libavformat/oggparsevorbis.c @@ -45,7 +45,7 @@ static int ogm_chapter(AVFormatContext *as, uint8_t *key, uint8_t *val) if (sscanf(val, "%02d:%02d:%02d.%03d", &h, &m, &s, &ms) < 4) return 0; - ff_new_chapter(as, cnum, (AVRational){1,1000}, + avpriv_new_chapter(as, cnum, (AVRational){1,1000}, ms + 1000*(s + 60*(m + 60*h)), AV_NOPTS_VALUE, NULL); av_free(val); diff --git a/libavformat/rtpenc_mpv.c b/libavformat/rtpenc_mpv.c index b23c8f86e8..0c617337b2 100644 --- a/libavformat/rtpenc_mpv.c +++ b/libavformat/rtpenc_mpv.c @@ -56,7 +56,7 @@ void ff_rtp_send_mpegvideo(AVFormatContext *s1, const uint8_t *buf1, int size) r1 = buf1; while (1) { start_code = -1; - r = ff_find_start_code(r1, end, &start_code); + r = avpriv_mpv_find_start_code(r1, end, &start_code); if((start_code & 0xFFFFFF00) == 0x100) { /* New start code found */ if (start_code == 0x100) { diff --git a/libavformat/sdp.c b/libavformat/sdp.c index 5f3ed1c4b1..37eee26485 100644 --- a/libavformat/sdp.c +++ b/libavformat/sdp.c @@ -252,7 +252,7 @@ static char *xiph_extradata2config(AVCodecContext *c) return NULL; } - if (ff_split_xiph_headers(c->extradata, c->extradata_size, + if (avpriv_split_xiph_headers(c->extradata, c->extradata_size, first_header_size, header_start, header_len) < 0) { av_log(c, AV_LOG_ERROR, "Extradata corrupt.\n"); @@ -342,7 +342,7 @@ static char *latm_context2config(AVCodecContext *c) char *config; for (rate_index = 0; rate_index < 16; rate_index++) - if (ff_mpeg4audio_sample_rates[rate_index] == c->sample_rate) + if (avpriv_mpeg4audio_sample_rates[rate_index] == c->sample_rate) break; if (rate_index == 16) { av_log(c, AV_LOG_ERROR, "Unsupported sample rate\n"); diff --git a/libavformat/spdifdec.c b/libavformat/spdifdec.c index 13ec2f0ebf..b0e9afb7b3 100644 --- a/libavformat/spdifdec.c +++ b/libavformat/spdifdec.c @@ -57,7 +57,7 @@ static int spdif_get_offset_and_codec(AVFormatContext *s, break; case IEC61937_MPEG2_AAC: init_get_bits(&gbc, buf, AAC_ADTS_HEADER_SIZE * 8); - if (ff_aac_parse_header(&gbc, &aac_hdr)) { + if (avpriv_aac_parse_header(&gbc, &aac_hdr)) { if (s) /* be silent during a probe */ av_log(s, AV_LOG_ERROR, "Invalid AAC packet in IEC 61937\n"); return AVERROR_INVALIDDATA; diff --git a/libavformat/spdifenc.c b/libavformat/spdifenc.c index 8602c0fee1..53aa27c446 100644 --- a/libavformat/spdifenc.c +++ b/libavformat/spdifenc.c @@ -349,7 +349,7 @@ static int spdif_header_aac(AVFormatContext *s, AVPacket *pkt) int ret; init_get_bits(&gbc, pkt->data, AAC_ADTS_HEADER_SIZE * 8); - ret = ff_aac_parse_header(&gbc, &hdr); + ret = avpriv_aac_parse_header(&gbc, &hdr); if (ret < 0) { av_log(s, AV_LOG_ERROR, "Wrong AAC file format\n"); return AVERROR_INVALIDDATA; diff --git a/libavformat/utils.c b/libavformat/utils.c index f00b1cb9c7..a788eefc34 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2143,7 +2143,6 @@ static int has_codec_parameters(AVCodecContext *avctx) avctx->codec_id == CODEC_ID_MP1 || avctx->codec_id == CODEC_ID_MP2 || avctx->codec_id == CODEC_ID_MP3 || - avctx->codec_id == CODEC_ID_SPEEX || avctx->codec_id == CODEC_ID_CELT)) return 0; break; @@ -2224,7 +2223,7 @@ enum CodecID ff_codec_get_id(const AVCodecTag *tags, unsigned int tag) return tags[i].id; } for(i=0; tags[i].id != CODEC_ID_NONE; i++) { - if (ff_toupper4(tag) == ff_toupper4(tags[i].tag)) + if (avpriv_toupper4(tag) == avpriv_toupper4(tags[i].tag)) return tags[i].id; } return CODEC_ID_NONE; @@ -2845,7 +2844,7 @@ AVProgram *av_new_program(AVFormatContext *ac, int id) return program; } -AVChapter *ff_new_chapter(AVFormatContext *s, int id, AVRational time_base, int64_t start, int64_t end, const char *title) +AVChapter *avpriv_new_chapter(AVFormatContext *s, int id, AVRational time_base, int64_t start, int64_t end, const char *title) { AVChapter *chapter = NULL; int i; @@ -2969,7 +2968,7 @@ static int validate_codec_tag(AVFormatContext *s, AVStream *st) for (n = 0; s->oformat->codec_tag[n]; n++) { avctag = s->oformat->codec_tag[n]; while (avctag->id != CODEC_ID_NONE) { - if (ff_toupper4(avctag->tag) == ff_toupper4(st->codec->codec_tag)) { + if (avpriv_toupper4(avctag->tag) == avpriv_toupper4(st->codec->codec_tag)) { id = avctag->id; if (id == st->codec->codec_id) return 1; diff --git a/tests/ref/fate/lossless-shortenaudio b/tests/ref/fate/lossless-shortenaudio index 9448052733..9cdb3690e3 100644 --- a/tests/ref/fate/lossless-shortenaudio +++ b/tests/ref/fate/lossless-shortenaudio @@ -1 +1 @@ -9949141c405524f37ef1058b1ef4114b +da93c50961443b88fce416ae61c8ca8a |