#include "avcodec.h"#include <faac.h>Go to the source code of this file.
Data Structures | |
| struct | FaacAudioContext |
Defines | |
| #define | free please_use_av_free |
Functions | |
| static av_cold int | Faac_encode_init (AVCodecContext *avctx) |
| static int | Faac_encode_frame (AVCodecContext *avctx, unsigned char *frame, int buf_size, void *data) |
| static av_cold int | Faac_encode_close (AVCodecContext *avctx) |
Variables | |
| AVCodec | libfaac_encoder |
Definition in file libfaac.c.
| #define free please_use_av_free |
Referenced by __attribute__(), addKeyword(), appendKeyword(), audio_decode_example(), audio_encode_example(), av_free(), cmovHandler(), doTest(), Efree(), EXTRACTOR_binaryEncode(), EXTRACTOR_common_cat_unpack(), EXTRACTOR_common_convert_to_utf8(), EXTRACTOR_freeKeywords(), EXTRACTOR_getKeywords(), EXTRACTOR_loadConfigLibraries(), EXTRACTOR_loadDefaultLibraries(), EXTRACTOR_printKeywords(), EXTRACTOR_removeEmptyKeywords(), EXTRACTOR_removeKeywordsOfType(), EXTRACTOR_removeLibrary(), Faac_encode_init(), formatHelp(), get_path_from_PATH(), getKeywords(), getSymbolWithPrefix(), history_extract(), iconvHelper(), libextractor_asf_extract(), libextractor_gif_extract(), libextractor_html_extract(), libextractor_id3v23_extract(), libextractor_id3v24_extract(), libextractor_id3v2_extract(), libextractor_mp3_extract(), libextractor_nsfe_auth_extract(), libextractor_nsfe_tlbl_extract(), libextractor_oo_extract(), libextractor_oo_getmimetype(), libextractor_pdf_extract(), libextractor_ps_extract(), libextractor_rpm_extract(), libextractor_split_extract(), libextractor_thumbnailgtk_extract(), libextractor_translit_extract(), libextractor_zip_extract(), main(), mp3parse(), os_get_installation_path(), parse_amf(), pgmyuv_save(), printSelectedKeywords(), printSelectedKeywordsBibtex(), printSelectedKeywordsGrepFriendly(), process(), processControl(), processControlTGZ(), processDataAtom(), processiTXt(), processMetadata(), processSO(), processTextTag(), processzTXt(), removeKeyword(), rmd160_destroy(), rmd160_sum_bytes(), splitKeywords(), stringDecode(), test(), testKeyword(), video_encode_example(), and wordTest().
| static av_cold int Faac_encode_close | ( | AVCodecContext * | avctx | ) | [static] |
Definition at line 135 of file libfaac.c.
References av_freep(), AVCodecContext::coded_frame, AVCodecContext::extradata, FaacAudioContext::faac_handle, and AVCodecContext::priv_data.
00136 { 00137 FaacAudioContext *s = avctx->priv_data; 00138 00139 av_freep(&avctx->coded_frame); 00140 av_freep(&avctx->extradata); 00141 00142 faacEncClose(s->faac_handle); 00143 return 0; 00144 }
| static int Faac_encode_frame | ( | AVCodecContext * | avctx, | |
| unsigned char * | frame, | |||
| int | buf_size, | |||
| void * | data | |||
| ) | [static] |
Definition at line 120 of file libfaac.c.
References AVCodecContext::channels, FaacAudioContext::faac_handle, AVCodecContext::frame_size, and AVCodecContext::priv_data.
00122 { 00123 FaacAudioContext *s = avctx->priv_data; 00124 int bytes_written; 00125 00126 bytes_written = faacEncEncode(s->faac_handle, 00127 data, 00128 avctx->frame_size * avctx->channels, 00129 frame, 00130 buf_size); 00131 00132 return bytes_written; 00133 }
| static av_cold int Faac_encode_init | ( | AVCodecContext * | avctx | ) | [static] |
Definition at line 34 of file libfaac.c.
References av_log(), AV_LOG_ERROR, av_malloc(), avcodec_alloc_frame(), AVCodecContext::bit_rate, AVCodecContext::channels, CODEC_FLAG_GLOBAL_HEADER, CODEC_FLAG_QSCALE, AVCodecContext::coded_frame, AVCodecContext::cutoff, AVCodecContext::extradata, AVCodecContext::extradata_size, FaacAudioContext::faac_handle, FF_INPUT_BUFFER_PADDING_SIZE, FF_PROFILE_AAC_LOW, FF_PROFILE_AAC_LTP, FF_PROFILE_AAC_MAIN, FF_PROFILE_AAC_SSR, FF_PROFILE_UNKNOWN, FF_QP2LAMBDA, AVCodecContext::flags, AVCodecContext::frame_size, free, AVCodecContext::global_quality, LOW, NULL, AVCodecContext::priv_data, AVCodecContext::profile, and AVCodecContext::sample_rate.
00035 { 00036 FaacAudioContext *s = avctx->priv_data; 00037 faacEncConfigurationPtr faac_cfg; 00038 unsigned long samples_input, max_bytes_output; 00039 00040 /* number of channels */ 00041 if (avctx->channels < 1 || avctx->channels > 6) 00042 return -1; 00043 00044 s->faac_handle = faacEncOpen(avctx->sample_rate, 00045 avctx->channels, 00046 &samples_input, &max_bytes_output); 00047 00048 /* check faac version */ 00049 faac_cfg = faacEncGetCurrentConfiguration(s->faac_handle); 00050 if (faac_cfg->version != FAAC_CFG_VERSION) { 00051 av_log(avctx, AV_LOG_ERROR, "wrong libfaac version (compiled for: %d, using %d)\n", FAAC_CFG_VERSION, faac_cfg->version); 00052 faacEncClose(s->faac_handle); 00053 return -1; 00054 } 00055 00056 /* put the options in the configuration struct */ 00057 switch(avctx->profile) { 00058 case FF_PROFILE_AAC_MAIN: 00059 faac_cfg->aacObjectType = MAIN; 00060 break; 00061 case FF_PROFILE_UNKNOWN: 00062 case FF_PROFILE_AAC_LOW: 00063 faac_cfg->aacObjectType = LOW; 00064 break; 00065 case FF_PROFILE_AAC_SSR: 00066 faac_cfg->aacObjectType = SSR; 00067 break; 00068 case FF_PROFILE_AAC_LTP: 00069 faac_cfg->aacObjectType = LTP; 00070 break; 00071 default: 00072 av_log(avctx, AV_LOG_ERROR, "invalid AAC profile\n"); 00073 faacEncClose(s->faac_handle); 00074 return -1; 00075 } 00076 faac_cfg->mpegVersion = MPEG4; 00077 faac_cfg->useTns = 0; 00078 faac_cfg->allowMidside = 1; 00079 faac_cfg->bitRate = avctx->bit_rate / avctx->channels; 00080 faac_cfg->bandWidth = avctx->cutoff; 00081 if(avctx->flags & CODEC_FLAG_QSCALE) { 00082 faac_cfg->bitRate = 0; 00083 faac_cfg->quantqual = avctx->global_quality / FF_QP2LAMBDA; 00084 } 00085 faac_cfg->outputFormat = 1; 00086 faac_cfg->inputFormat = FAAC_INPUT_16BIT; 00087 00088 avctx->frame_size = samples_input / avctx->channels; 00089 00090 avctx->coded_frame= avcodec_alloc_frame(); 00091 avctx->coded_frame->key_frame= 1; 00092 00093 /* Set decoder specific info */ 00094 avctx->extradata_size = 0; 00095 if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { 00096 00097 unsigned char *buffer = NULL; 00098 unsigned long decoder_specific_info_size; 00099 00100 if (!faacEncGetDecoderSpecificInfo(s->faac_handle, &buffer, 00101 &decoder_specific_info_size)) { 00102 avctx->extradata = av_malloc(decoder_specific_info_size + FF_INPUT_BUFFER_PADDING_SIZE); 00103 avctx->extradata_size = decoder_specific_info_size; 00104 memcpy(avctx->extradata, buffer, avctx->extradata_size); 00105 faac_cfg->outputFormat = 0; 00106 } 00107 #undef free 00108 free(buffer); 00109 #define free please_use_av_free 00110 } 00111 00112 if (!faacEncSetConfiguration(s->faac_handle, faac_cfg)) { 00113 av_log(avctx, AV_LOG_ERROR, "libfaac doesn't support this output format!\n"); 00114 return -1; 00115 } 00116 00117 return 0; 00118 }
Initial value:
{
"libfaac",
CODEC_TYPE_AUDIO,
CODEC_ID_AAC,
sizeof(FaacAudioContext),
Faac_encode_init,
Faac_encode_frame,
Faac_encode_close,
.long_name = NULL_IF_CONFIG_SMALL("libfaac AAC (Advanced Audio Codec)"),
}
1.5.1