avcodec.h 93 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003
  1. /*
  2. * copyright (c) 2001 Fabrice Bellard
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #ifndef FFMPEG_AVCODEC_H
  21. #define FFMPEG_AVCODEC_H
  22. /**
  23. * @file avcodec.h
  24. * external API header
  25. */
  26. #include "libavutil/avutil.h"
  27. #include <sys/types.h> /* size_t */
  28. #define LIBAVCODEC_VERSION_MAJOR 51
  29. #define LIBAVCODEC_VERSION_MINOR 51
  30. #define LIBAVCODEC_VERSION_MICRO 0
  31. #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
  32. LIBAVCODEC_VERSION_MINOR, \
  33. LIBAVCODEC_VERSION_MICRO)
  34. #define LIBAVCODEC_VERSION AV_VERSION(LIBAVCODEC_VERSION_MAJOR, \
  35. LIBAVCODEC_VERSION_MINOR, \
  36. LIBAVCODEC_VERSION_MICRO)
  37. #define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT
  38. #define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)
  39. #define AV_NOPTS_VALUE INT64_C(0x8000000000000000)
  40. #define AV_TIME_BASE 1000000
  41. #define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE}
  42. /**
  43. * Identifies the syntax and semantics of the bitstream.
  44. * The principle is roughly:
  45. * Two decoders with the same ID can decode the same streams.
  46. * Two encoders with the same ID can encode compatible streams.
  47. * There may be slight deviations from the principle due to implementation
  48. * details.
  49. *
  50. * If you add a codec ID to this list, add it so that
  51. * 1. no value of a existing codec ID changes (that would break ABI),
  52. * 2. it is as close as possible to similar codecs.
  53. */
  54. enum CodecID {
  55. CODEC_ID_NONE,
  56. CODEC_ID_MPEG1VIDEO,
  57. CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding
  58. CODEC_ID_MPEG2VIDEO_XVMC,
  59. CODEC_ID_H261,
  60. CODEC_ID_H263,
  61. CODEC_ID_RV10,
  62. CODEC_ID_RV20,
  63. CODEC_ID_MJPEG,
  64. CODEC_ID_MJPEGB,
  65. CODEC_ID_LJPEG,
  66. CODEC_ID_SP5X,
  67. CODEC_ID_JPEGLS,
  68. CODEC_ID_MPEG4,
  69. CODEC_ID_RAWVIDEO,
  70. CODEC_ID_MSMPEG4V1,
  71. CODEC_ID_MSMPEG4V2,
  72. CODEC_ID_MSMPEG4V3,
  73. CODEC_ID_WMV1,
  74. CODEC_ID_WMV2,
  75. CODEC_ID_H263P,
  76. CODEC_ID_H263I,
  77. CODEC_ID_FLV1,
  78. CODEC_ID_SVQ1,
  79. CODEC_ID_SVQ3,
  80. CODEC_ID_DVVIDEO,
  81. CODEC_ID_HUFFYUV,
  82. CODEC_ID_CYUV,
  83. CODEC_ID_H264,
  84. CODEC_ID_INDEO3,
  85. CODEC_ID_VP3,
  86. CODEC_ID_THEORA,
  87. CODEC_ID_ASV1,
  88. CODEC_ID_ASV2,
  89. CODEC_ID_FFV1,
  90. CODEC_ID_4XM,
  91. CODEC_ID_VCR1,
  92. CODEC_ID_CLJR,
  93. CODEC_ID_MDEC,
  94. CODEC_ID_ROQ,
  95. CODEC_ID_INTERPLAY_VIDEO,
  96. CODEC_ID_XAN_WC3,
  97. CODEC_ID_XAN_WC4,
  98. CODEC_ID_RPZA,
  99. CODEC_ID_CINEPAK,
  100. CODEC_ID_WS_VQA,
  101. CODEC_ID_MSRLE,
  102. CODEC_ID_MSVIDEO1,
  103. CODEC_ID_IDCIN,
  104. CODEC_ID_8BPS,
  105. CODEC_ID_SMC,
  106. CODEC_ID_FLIC,
  107. CODEC_ID_TRUEMOTION1,
  108. CODEC_ID_VMDVIDEO,
  109. CODEC_ID_MSZH,
  110. CODEC_ID_ZLIB,
  111. CODEC_ID_QTRLE,
  112. CODEC_ID_SNOW,
  113. CODEC_ID_TSCC,
  114. CODEC_ID_ULTI,
  115. CODEC_ID_QDRAW,
  116. CODEC_ID_VIXL,
  117. CODEC_ID_QPEG,
  118. CODEC_ID_XVID,
  119. CODEC_ID_PNG,
  120. CODEC_ID_PPM,
  121. CODEC_ID_PBM,
  122. CODEC_ID_PGM,
  123. CODEC_ID_PGMYUV,
  124. CODEC_ID_PAM,
  125. CODEC_ID_FFVHUFF,
  126. CODEC_ID_RV30,
  127. CODEC_ID_RV40,
  128. CODEC_ID_VC1,
  129. CODEC_ID_WMV3,
  130. CODEC_ID_LOCO,
  131. CODEC_ID_WNV1,
  132. CODEC_ID_AASC,
  133. CODEC_ID_INDEO2,
  134. CODEC_ID_FRAPS,
  135. CODEC_ID_TRUEMOTION2,
  136. CODEC_ID_BMP,
  137. CODEC_ID_CSCD,
  138. CODEC_ID_MMVIDEO,
  139. CODEC_ID_ZMBV,
  140. CODEC_ID_AVS,
  141. CODEC_ID_SMACKVIDEO,
  142. CODEC_ID_NUV,
  143. CODEC_ID_KMVC,
  144. CODEC_ID_FLASHSV,
  145. CODEC_ID_CAVS,
  146. CODEC_ID_JPEG2000,
  147. CODEC_ID_VMNC,
  148. CODEC_ID_VP5,
  149. CODEC_ID_VP6,
  150. CODEC_ID_VP6F,
  151. CODEC_ID_TARGA,
  152. CODEC_ID_DSICINVIDEO,
  153. CODEC_ID_TIERTEXSEQVIDEO,
  154. CODEC_ID_TIFF,
  155. CODEC_ID_GIF,
  156. CODEC_ID_FFH264,
  157. CODEC_ID_DXA,
  158. CODEC_ID_DNXHD,
  159. CODEC_ID_THP,
  160. CODEC_ID_SGI,
  161. CODEC_ID_C93,
  162. CODEC_ID_BETHSOFTVID,
  163. CODEC_ID_PTX,
  164. CODEC_ID_TXD,
  165. CODEC_ID_VP6A,
  166. CODEC_ID_AMV,
  167. CODEC_ID_VB,
  168. CODEC_ID_PCX,
  169. CODEC_ID_SUNRAST,
  170. CODEC_ID_INDEO4,
  171. CODEC_ID_INDEO5,
  172. /* various PCM "codecs" */
  173. CODEC_ID_PCM_S16LE= 0x10000,
  174. CODEC_ID_PCM_S16BE,
  175. CODEC_ID_PCM_U16LE,
  176. CODEC_ID_PCM_U16BE,
  177. CODEC_ID_PCM_S8,
  178. CODEC_ID_PCM_U8,
  179. CODEC_ID_PCM_MULAW,
  180. CODEC_ID_PCM_ALAW,
  181. CODEC_ID_PCM_S32LE,
  182. CODEC_ID_PCM_S32BE,
  183. CODEC_ID_PCM_U32LE,
  184. CODEC_ID_PCM_U32BE,
  185. CODEC_ID_PCM_S24LE,
  186. CODEC_ID_PCM_S24BE,
  187. CODEC_ID_PCM_U24LE,
  188. CODEC_ID_PCM_U24BE,
  189. CODEC_ID_PCM_S24DAUD,
  190. CODEC_ID_PCM_ZORK,
  191. CODEC_ID_PCM_S16LE_PLANAR,
  192. /* various ADPCM codecs */
  193. CODEC_ID_ADPCM_IMA_QT= 0x11000,
  194. CODEC_ID_ADPCM_IMA_WAV,
  195. CODEC_ID_ADPCM_IMA_DK3,
  196. CODEC_ID_ADPCM_IMA_DK4,
  197. CODEC_ID_ADPCM_IMA_WS,
  198. CODEC_ID_ADPCM_IMA_SMJPEG,
  199. CODEC_ID_ADPCM_MS,
  200. CODEC_ID_ADPCM_4XM,
  201. CODEC_ID_ADPCM_XA,
  202. CODEC_ID_ADPCM_ADX,
  203. CODEC_ID_ADPCM_EA,
  204. CODEC_ID_ADPCM_G726,
  205. CODEC_ID_ADPCM_CT,
  206. CODEC_ID_ADPCM_SWF,
  207. CODEC_ID_ADPCM_YAMAHA,
  208. CODEC_ID_ADPCM_SBPRO_4,
  209. CODEC_ID_ADPCM_SBPRO_3,
  210. CODEC_ID_ADPCM_SBPRO_2,
  211. CODEC_ID_ADPCM_THP,
  212. CODEC_ID_ADPCM_IMA_AMV,
  213. CODEC_ID_ADPCM_EA_R1,
  214. CODEC_ID_ADPCM_EA_R3,
  215. CODEC_ID_ADPCM_EA_R2,
  216. CODEC_ID_ADPCM_IMA_EA_SEAD,
  217. CODEC_ID_ADPCM_IMA_EA_EACS,
  218. CODEC_ID_ADPCM_EA_XAS,
  219. /* AMR */
  220. CODEC_ID_AMR_NB= 0x12000,
  221. CODEC_ID_AMR_WB,
  222. /* RealAudio codecs*/
  223. CODEC_ID_RA_144= 0x13000,
  224. CODEC_ID_RA_288,
  225. /* various DPCM codecs */
  226. CODEC_ID_ROQ_DPCM= 0x14000,
  227. CODEC_ID_INTERPLAY_DPCM,
  228. CODEC_ID_XAN_DPCM,
  229. CODEC_ID_SOL_DPCM,
  230. CODEC_ID_MP2= 0x15000,
  231. CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3
  232. CODEC_ID_AAC,
  233. #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
  234. CODEC_ID_MPEG4AAC,
  235. #endif
  236. CODEC_ID_AC3,
  237. CODEC_ID_DTS,
  238. CODEC_ID_VORBIS,
  239. CODEC_ID_DVAUDIO,
  240. CODEC_ID_WMAV1,
  241. CODEC_ID_WMAV2,
  242. CODEC_ID_MACE3,
  243. CODEC_ID_MACE6,
  244. CODEC_ID_VMDAUDIO,
  245. CODEC_ID_SONIC,
  246. CODEC_ID_SONIC_LS,
  247. CODEC_ID_FLAC,
  248. CODEC_ID_MP3ADU,
  249. CODEC_ID_MP3ON4,
  250. CODEC_ID_SHORTEN,
  251. CODEC_ID_ALAC,
  252. CODEC_ID_WESTWOOD_SND1,
  253. CODEC_ID_GSM, ///< as in Berlin toast format
  254. CODEC_ID_QDM2,
  255. CODEC_ID_COOK,
  256. CODEC_ID_TRUESPEECH,
  257. CODEC_ID_TTA,
  258. CODEC_ID_SMACKAUDIO,
  259. CODEC_ID_QCELP,
  260. CODEC_ID_WAVPACK,
  261. CODEC_ID_DSICINAUDIO,
  262. CODEC_ID_IMC,
  263. CODEC_ID_MUSEPACK7,
  264. CODEC_ID_MLP,
  265. CODEC_ID_GSM_MS, /* as found in WAV */
  266. CODEC_ID_ATRAC3,
  267. CODEC_ID_VOXWARE,
  268. CODEC_ID_APE,
  269. CODEC_ID_NELLYMOSER,
  270. CODEC_ID_MUSEPACK8,
  271. CODEC_ID_SPEEX,
  272. CODEC_ID_WMAVOICE,
  273. CODEC_ID_WMAPRO,
  274. CODEC_ID_WMALOSSLESS,
  275. /* subtitle codecs */
  276. CODEC_ID_DVD_SUBTITLE= 0x17000,
  277. CODEC_ID_DVB_SUBTITLE,
  278. CODEC_ID_TEXT, ///< raw UTF-8 text
  279. CODEC_ID_XSUB,
  280. CODEC_ID_SSA,
  281. CODEC_ID_MOV_TEXT,
  282. /* other specific kind of codecs (generally used for attachments) */
  283. CODEC_ID_TTF= 0x18000,
  284. CODEC_ID_MPEG2TS= 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS
  285. * stream (only used by libavformat) */
  286. };
  287. #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
  288. /* CODEC_ID_MP3LAME is obsolete */
  289. #define CODEC_ID_MP3LAME CODEC_ID_MP3
  290. #define CODEC_ID_MPEG4AAC CODEC_ID_AAC
  291. #endif
  292. enum CodecType {
  293. CODEC_TYPE_UNKNOWN = -1,
  294. CODEC_TYPE_VIDEO,
  295. CODEC_TYPE_AUDIO,
  296. CODEC_TYPE_DATA,
  297. CODEC_TYPE_SUBTITLE,
  298. CODEC_TYPE_ATTACHMENT,
  299. CODEC_TYPE_NB
  300. };
  301. /**
  302. * Currently unused, may be used if 24/32 bits samples are ever supported.
  303. * all in native-endian format
  304. */
  305. enum SampleFormat {
  306. SAMPLE_FMT_NONE = -1,
  307. SAMPLE_FMT_U8, ///< unsigned 8 bits
  308. SAMPLE_FMT_S16, ///< signed 16 bits
  309. SAMPLE_FMT_S24, ///< signed 24 bits
  310. SAMPLE_FMT_S32, ///< signed 32 bits
  311. SAMPLE_FMT_FLT, ///< float
  312. };
  313. /* in bytes */
  314. #define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
  315. /**
  316. * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
  317. * This is mainly needed because some optimized bitstream readers read
  318. * 32 or 64 bit at once and could read over the end.<br>
  319. * Note: If the first 23 bits of the additional bytes are not 0, then damaged
  320. * MPEG bitstreams could cause overread and segfault.
  321. */
  322. #define FF_INPUT_BUFFER_PADDING_SIZE 8
  323. /**
  324. * minimum encoding buffer size
  325. * Used to avoid some checks during header writing.
  326. */
  327. #define FF_MIN_BUFFER_SIZE 16384
  328. /**
  329. * motion estimation type.
  330. */
  331. enum Motion_Est_ID {
  332. ME_ZERO = 1, ///< no search, that is use 0,0 vector whenever one is needed
  333. ME_FULL,
  334. ME_LOG,
  335. ME_PHODS,
  336. ME_EPZS, ///< enhanced predictive zonal search
  337. ME_X1, ///< reserved for experiments
  338. ME_HEX, ///< hexagon based search
  339. ME_UMH, ///< uneven multi-hexagon search
  340. ME_ITER, ///< iterative search
  341. };
  342. enum AVDiscard{
  343. /* We leave some space between them for extensions (drop some
  344. * keyframes for intra-only or drop just some bidir frames). */
  345. AVDISCARD_NONE =-16, ///< discard nothing
  346. AVDISCARD_DEFAULT= 0, ///< discard useless packets like 0 size packets in avi
  347. AVDISCARD_NONREF = 8, ///< discard all non reference
  348. AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames
  349. AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes
  350. AVDISCARD_ALL = 48, ///< discard all
  351. };
  352. typedef struct RcOverride{
  353. int start_frame;
  354. int end_frame;
  355. int qscale; // If this is 0 then quality_factor will be used instead.
  356. float quality_factor;
  357. } RcOverride;
  358. #define FF_MAX_B_FRAMES 16
  359. /* encoding support
  360. These flags can be passed in AVCodecContext.flags before initialization.
  361. Note: Not everything is supported yet.
  362. */
  363. #define CODEC_FLAG_QSCALE 0x0002 ///< Use fixed qscale.
  364. #define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / advanced prediction for H.263.
  365. #define CODEC_FLAG_QPEL 0x0010 ///< Use qpel MC.
  366. #define CODEC_FLAG_GMC 0x0020 ///< Use GMC.
  367. #define CODEC_FLAG_MV0 0x0040 ///< Always try a MB with MV=<0,0>.
  368. #define CODEC_FLAG_PART 0x0080 ///< Use data partitioning.
  369. /**
  370. * The parent program guarantees that the input for B-frames containing
  371. * streams is not written to for at least s->max_b_frames+1 frames, if
  372. * this is not set the input will be copied.
  373. */
  374. #define CODEC_FLAG_INPUT_PRESERVED 0x0100
  375. #define CODEC_FLAG_PASS1 0x0200 ///< Use internal 2pass ratecontrol in first pass mode.
  376. #define CODEC_FLAG_PASS2 0x0400 ///< Use internal 2pass ratecontrol in second pass mode.
  377. #define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< Use external Huffman table (for MJPEG).
  378. #define CODEC_FLAG_GRAY 0x2000 ///< Only decode/encode grayscale.
  379. #define CODEC_FLAG_EMU_EDGE 0x4000 ///< Don't draw edges.
  380. #define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding.
  381. #define CODEC_FLAG_TRUNCATED 0x00010000 /** Input bitstream might be truncated at a random
  382. location instead of only at frame boundaries. */
  383. #define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< Normalize adaptive quantization.
  384. #define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< Use interlaced DCT.
  385. #define CODEC_FLAG_LOW_DELAY 0x00080000 ///< Force low delay.
  386. #define CODEC_FLAG_ALT_SCAN 0x00100000 ///< Use alternate scan.
  387. #define CODEC_FLAG_TRELLIS_QUANT 0x00200000 ///< Use trellis quantization.
  388. #define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< Place global headers in extradata instead of every keyframe.
  389. #define CODEC_FLAG_BITEXACT 0x00800000 ///< Use only bitexact stuff (except (I)DCT).
  390. /* Fx : Flag for h263+ extra options */
  391. #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
  392. #define CODEC_FLAG_H263P_AIC 0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction (remove this)
  393. #endif
  394. #define CODEC_FLAG_AC_PRED 0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction
  395. #define CODEC_FLAG_H263P_UMV 0x02000000 ///< unlimited motion vector
  396. #define CODEC_FLAG_CBP_RD 0x04000000 ///< Use rate distortion optimization for cbp.
  397. #define CODEC_FLAG_QP_RD 0x08000000 ///< Use rate distortion optimization for qp selectioon.
  398. #define CODEC_FLAG_H263P_AIV 0x00000008 ///< H.263 alternative inter VLC
  399. #define CODEC_FLAG_OBMC 0x00000001 ///< OBMC
  400. #define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter
  401. #define CODEC_FLAG_H263P_SLICE_STRUCT 0x10000000
  402. #define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation
  403. #define CODEC_FLAG_SVCD_SCAN_OFFSET 0x40000000 ///< Will reserve space for SVCD scan offset user data.
  404. #define CODEC_FLAG_CLOSED_GOP ((int)0x80000000)
  405. #define CODEC_FLAG2_FAST 0x00000001 ///< Allow non spec compliant speedup tricks.
  406. #define CODEC_FLAG2_STRICT_GOP 0x00000002 ///< Strictly enforce GOP size.
  407. #define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< Skip bitstream encoding.
  408. #define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< Place global headers at every keyframe instead of in extradata.
  409. #define CODEC_FLAG2_BPYRAMID 0x00000010 ///< H.264 allow B-frames to be used as references.
  410. #define CODEC_FLAG2_WPRED 0x00000020 ///< H.264 weighted biprediction for B-frames
  411. #define CODEC_FLAG2_MIXED_REFS 0x00000040 ///< H.264 one reference per partition, as opposed to one reference per macroblock
  412. #define CODEC_FLAG2_8X8DCT 0x00000080 ///< H.264 high profile 8x8 transform
  413. #define CODEC_FLAG2_FASTPSKIP 0x00000100 ///< H.264 fast pskip
  414. #define CODEC_FLAG2_AUD 0x00000200 ///< H.264 access unit delimiters
  415. #define CODEC_FLAG2_BRDO 0x00000400 ///< B-frame rate-distortion optimization
  416. #define CODEC_FLAG2_INTRA_VLC 0x00000800 ///< Use MPEG-2 intra VLC table.
  417. #define CODEC_FLAG2_MEMC_ONLY 0x00001000 ///< Only do ME/MC (I frames -> ref, P frame -> ME+MC).
  418. #define CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 ///< timecode is in drop frame format.
  419. #define CODEC_FLAG2_SKIP_RD 0x00004000 ///< RD optimal MB level residual skipping
  420. #define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries.
  421. #define CODEC_FLAG2_NON_LINEAR_QUANT 0x00010000 ///< Use MPEG-2 nonlinear quantizer.
  422. #define CODEC_FLAG2_BIT_RESERVOIR 0x00020000 ///< Use a bit reservoir when encoding if possible
  423. /* Unsupported options :
  424. * Syntax Arithmetic coding (SAC)
  425. * Reference Picture Selection
  426. * Independent Segment Decoding */
  427. /* /Fx */
  428. /* codec capabilities */
  429. #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< Decoder can use draw_horiz_band callback.
  430. /**
  431. * Codec uses get_buffer() for allocating buffers.
  432. * direct rendering method 1
  433. */
  434. #define CODEC_CAP_DR1 0x0002
  435. /* If 'parse_only' field is true, then avcodec_parse_frame() can be used. */
  436. #define CODEC_CAP_PARSE_ONLY 0x0004
  437. #define CODEC_CAP_TRUNCATED 0x0008
  438. /* Codec can export data for HW decoding (XvMC). */
  439. #define CODEC_CAP_HWACCEL 0x0010
  440. /**
  441. * Codec has a nonzero delay and needs to be fed with NULL at the end to get the delayed data.
  442. * If this is not set, the codec is guaranteed to never be fed with NULL data.
  443. */
  444. #define CODEC_CAP_DELAY 0x0020
  445. /**
  446. * Codec can be fed a final frame with a smaller size.
  447. * This can be used to prevent truncation of the last audio samples.
  448. */
  449. #define CODEC_CAP_SMALL_LAST_FRAME 0x0040
  450. //The following defines may change, don't expect compatibility if you use them.
  451. #define MB_TYPE_INTRA4x4 0x0001
  452. #define MB_TYPE_INTRA16x16 0x0002 //FIXME H.264-specific
  453. #define MB_TYPE_INTRA_PCM 0x0004 //FIXME H.264-specific
  454. #define MB_TYPE_16x16 0x0008
  455. #define MB_TYPE_16x8 0x0010
  456. #define MB_TYPE_8x16 0x0020
  457. #define MB_TYPE_8x8 0x0040
  458. #define MB_TYPE_INTERLACED 0x0080
  459. #define MB_TYPE_DIRECT2 0x0100 //FIXME
  460. #define MB_TYPE_ACPRED 0x0200
  461. #define MB_TYPE_GMC 0x0400
  462. #define MB_TYPE_SKIP 0x0800
  463. #define MB_TYPE_P0L0 0x1000
  464. #define MB_TYPE_P1L0 0x2000
  465. #define MB_TYPE_P0L1 0x4000
  466. #define MB_TYPE_P1L1 0x8000
  467. #define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0)
  468. #define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1)
  469. #define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1)
  470. #define MB_TYPE_QUANT 0x00010000
  471. #define MB_TYPE_CBP 0x00020000
  472. //Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...)
  473. /**
  474. * Pan Scan area.
  475. * This specifies the area which should be displayed.
  476. * Note there may be multiple such areas for one frame.
  477. */
  478. typedef struct AVPanScan{
  479. /**
  480. * id
  481. * - encoding: Set by user.
  482. * - decoding: Set by libavcodec.
  483. */
  484. int id;
  485. /**
  486. * width and height in 1/16 pel
  487. * - encoding: Set by user.
  488. * - decoding: Set by libavcodec.
  489. */
  490. int width;
  491. int height;
  492. /**
  493. * position of the top left corner in 1/16 pel for up to 3 fields/frames
  494. * - encoding: Set by user.
  495. * - decoding: Set by libavcodec.
  496. */
  497. int16_t position[3][2];
  498. }AVPanScan;
  499. #define FF_COMMON_FRAME \
  500. /**\
  501. * pointer to the picture planes.\
  502. * This might be different from the first allocated byte\
  503. * - encoding: \
  504. * - decoding: \
  505. */\
  506. uint8_t *data[4];\
  507. int linesize[4];\
  508. /**\
  509. * pointer to the first allocated byte of the picture. Can be used in get_buffer/release_buffer.\
  510. * This isn't used by libavcodec unless the default get/release_buffer() is used.\
  511. * - encoding: \
  512. * - decoding: \
  513. */\
  514. uint8_t *base[4];\
  515. /**\
  516. * 1 -> keyframe, 0-> not\
  517. * - encoding: Set by libavcodec.\
  518. * - decoding: Set by libavcodec.\
  519. */\
  520. int key_frame;\
  521. \
  522. /**\
  523. * Picture type of the frame, see ?_TYPE below.\
  524. * - encoding: Set by libavcodec. for coded_picture (and set by user for input).\
  525. * - decoding: Set by libavcodec.\
  526. */\
  527. int pict_type;\
  528. \
  529. /**\
  530. * presentation timestamp in time_base units (time when frame should be shown to user)\
  531. * If AV_NOPTS_VALUE then frame_rate = 1/time_base will be assumed.\
  532. * - encoding: MUST be set by user.\
  533. * - decoding: Set by libavcodec.\
  534. */\
  535. int64_t pts;\
  536. \
  537. /**\
  538. * picture number in bitstream order\
  539. * - encoding: set by\
  540. * - decoding: Set by libavcodec.\
  541. */\
  542. int coded_picture_number;\
  543. /**\
  544. * picture number in display order\
  545. * - encoding: set by\
  546. * - decoding: Set by libavcodec.\
  547. */\
  548. int display_picture_number;\
  549. \
  550. /**\
  551. * quality (between 1 (good) and FF_LAMBDA_MAX (bad)) \
  552. * - encoding: Set by libavcodec. for coded_picture (and set by user for input).\
  553. * - decoding: Set by libavcodec.\
  554. */\
  555. int quality; \
  556. \
  557. /**\
  558. * buffer age (1->was last buffer and dint change, 2->..., ...).\
  559. * Set to INT_MAX if the buffer has not been used yet.\
  560. * - encoding: unused\
  561. * - decoding: MUST be set by get_buffer().\
  562. */\
  563. int age;\
  564. \
  565. /**\
  566. * is this picture used as reference\
  567. * - encoding: unused\
  568. * - decoding: Set by libavcodec. (before get_buffer() call)).\
  569. */\
  570. int reference;\
  571. \
  572. /**\
  573. * QP table\
  574. * - encoding: unused\
  575. * - decoding: Set by libavcodec.\
  576. */\
  577. int8_t *qscale_table;\
  578. /**\
  579. * QP store stride\
  580. * - encoding: unused\
  581. * - decoding: Set by libavcodec.\
  582. */\
  583. int qstride;\
  584. \
  585. /**\
  586. * mbskip_table[mb]>=1 if MB didn't change\
  587. * stride= mb_width = (width+15)>>4\
  588. * - encoding: unused\
  589. * - decoding: Set by libavcodec.\
  590. */\
  591. uint8_t *mbskip_table;\
  592. \
  593. /**\
  594. * motion vector table\
  595. * @code\
  596. * example:\
  597. * int mv_sample_log2= 4 - motion_subsample_log2;\
  598. * int mb_width= (width+15)>>4;\
  599. * int mv_stride= (mb_width << mv_sample_log2) + 1;\
  600. * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y];\
  601. * @endcode\
  602. * - encoding: Set by user.\
  603. * - decoding: Set by libavcodec.\
  604. */\
  605. int16_t (*motion_val[2])[2];\
  606. \
  607. /**\
  608. * macroblock type table\
  609. * mb_type_base + mb_width + 2\
  610. * - encoding: Set by user.\
  611. * - decoding: Set by libavcodec.\
  612. */\
  613. uint32_t *mb_type;\
  614. \
  615. /**\
  616. * log2 of the size of the block which a single vector in motion_val represents: \
  617. * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2)\
  618. * - encoding: unused\
  619. * - decoding: Set by libavcodec.\
  620. */\
  621. uint8_t motion_subsample_log2;\
  622. \
  623. /**\
  624. * for some private data of the user\
  625. * - encoding: unused\
  626. * - decoding: Set by user.\
  627. */\
  628. void *opaque;\
  629. \
  630. /**\
  631. * error\
  632. * - encoding: Set by libavcodec. if flags&CODEC_FLAG_PSNR.\
  633. * - decoding: unused\
  634. */\
  635. uint64_t error[4];\
  636. \
  637. /**\
  638. * type of the buffer (to keep track of who has to deallocate data[*])\
  639. * - encoding: Set by the one who allocates it.\
  640. * - decoding: Set by the one who allocates it.\
  641. * Note: User allocated (direct rendering) & internal buffers cannot coexist currently.\
  642. */\
  643. int type;\
  644. \
  645. /**\
  646. * When decoding, this signals how much the picture must be delayed.\
  647. * extra_delay = repeat_pict / (2*fps)\
  648. * - encoding: unused\
  649. * - decoding: Set by libavcodec.\
  650. */\
  651. int repeat_pict;\
  652. \
  653. /**\
  654. * \
  655. */\
  656. int qscale_type;\
  657. \
  658. /**\
  659. * The content of the picture is interlaced.\
  660. * - encoding: Set by user.\
  661. * - decoding: Set by libavcodec. (default 0)\
  662. */\
  663. int interlaced_frame;\
  664. \
  665. /**\
  666. * If the content is interlaced, is top field displayed first.\
  667. * - encoding: Set by user.\
  668. * - decoding: Set by libavcodec.\
  669. */\
  670. int top_field_first;\
  671. \
  672. /**\
  673. * Pan scan.\
  674. * - encoding: Set by user.\
  675. * - decoding: Set by libavcodec.\
  676. */\
  677. AVPanScan *pan_scan;\
  678. \
  679. /**\
  680. * Tell user application that palette has changed from previous frame.\
  681. * - encoding: ??? (no palette-enabled encoder yet)\
  682. * - decoding: Set by libavcodec. (default 0).\
  683. */\
  684. int palette_has_changed;\
  685. \
  686. /**\
  687. * codec suggestion on buffer type if != 0\
  688. * - encoding: unused\
  689. * - decoding: Set by libavcodec. (before get_buffer() call)).\
  690. */\
  691. int buffer_hints;\
  692. \
  693. /**\
  694. * DCT coefficients\
  695. * - encoding: unused\
  696. * - decoding: Set by libavcodec.\
  697. */\
  698. short *dct_coeff;\
  699. \
  700. /**\
  701. * motion referece frame index\
  702. * - encoding: Set by user.\
  703. * - decoding: Set by libavcodec.\
  704. */\
  705. int8_t *ref_index[2];
  706. #define FF_QSCALE_TYPE_MPEG1 0
  707. #define FF_QSCALE_TYPE_MPEG2 1
  708. #define FF_QSCALE_TYPE_H264 2
  709. #define FF_BUFFER_TYPE_INTERNAL 1
  710. #define FF_BUFFER_TYPE_USER 2 ///< direct rendering buffers (image is (de)allocated by user)
  711. #define FF_BUFFER_TYPE_SHARED 4 ///< Buffer from somewhere else; don't deallocate image (data/base), all other tables are not shared.
  712. #define FF_BUFFER_TYPE_COPY 8 ///< Just a (modified) copy of some other buffer, don't deallocate anything.
  713. #define FF_I_TYPE 1 ///< Intra
  714. #define FF_P_TYPE 2 ///< Predicted
  715. #define FF_B_TYPE 3 ///< Bi-dir predicted
  716. #define FF_S_TYPE 4 ///< S(GMC)-VOP MPEG4
  717. #define FF_SI_TYPE 5 ///< Switching Intra
  718. #define FF_SP_TYPE 6 ///< Switching Predicted
  719. #define FF_BI_TYPE 7
  720. #define FF_BUFFER_HINTS_VALID 0x01 // Buffer hints value is meaningful (if 0 ignore).
  721. #define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer.
  722. #define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content.
  723. #define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update).
  724. /**
  725. * Audio Video Frame.
  726. * New fields can be added to the end of FF_COMMON_FRAME with minor version
  727. * bumps.
  728. * Removal, reordering and changes to existing fields require a major
  729. * version bump. No fields should be added into AVFrame before or after
  730. * FF_COMMON_FRAME!
  731. * sizeof(AVFrame) must not be used outside libav*.
  732. */
  733. typedef struct AVFrame {
  734. FF_COMMON_FRAME
  735. } AVFrame;
  736. #define DEFAULT_FRAME_RATE_BASE 1001000
  737. /**
  738. * main external API structure.
  739. * New fields can be added to the end with minor version bumps.
  740. * Removal, reordering and changes to existing fields require a major
  741. * version bump.
  742. * sizeof(AVCodecContext) must not be used outside libav*.
  743. */
  744. typedef struct AVCodecContext {
  745. /**
  746. * information on struct for av_log
  747. * - set by avcodec_alloc_context
  748. */
  749. const AVClass *av_class;
  750. /**
  751. * the average bitrate
  752. * - encoding: Set by user; unused for constant quantizer encoding.
  753. * - decoding: Set by libavcodec. 0 or some bitrate if this info is available in the stream.
  754. */
  755. int bit_rate;
  756. /**
  757. * number of bits the bitstream is allowed to diverge from the reference.
  758. * the reference can be CBR (for CBR pass1) or VBR (for pass2)
  759. * - encoding: Set by user; unused for constant quantizer encoding.
  760. * - decoding: unused
  761. */
  762. int bit_rate_tolerance;
  763. /**
  764. * CODEC_FLAG_*.
  765. * - encoding: Set by user.
  766. * - decoding: Set by user.
  767. */
  768. int flags;
  769. /**
  770. * Some codecs need additional format info. It is stored here.
  771. * If any muxer uses this then ALL demuxers/parsers AND encoders for the
  772. * specific codec MUST set it correctly otherwise stream copy breaks.
  773. * In general use of this field by muxers is not recommanded.
  774. * - encoding: Set by libavcodec.
  775. * - decoding: Set by libavcodec. (FIXME: Is this OK?)
  776. */
  777. int sub_id;
  778. /**
  779. * Motion estimation algorithm used for video coding.
  780. * 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex),
  781. * 8 (umh), 9 (iter) [7, 8 are x264 specific, 9 is snow specific]
  782. * - encoding: MUST be set by user.
  783. * - decoding: unused
  784. */
  785. int me_method;
  786. /**
  787. * some codecs need / can use extradata like Huffman tables.
  788. * mjpeg: Huffman tables
  789. * rv10: additional flags
  790. * mpeg4: global headers (they can be in the bitstream or here)
  791. * The allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger
  792. * than extradata_size to avoid prolems if it is read with the bitstream reader.
  793. * The bytewise contents of extradata must not depend on the architecture or CPU endianness.
  794. * - encoding: Set/allocated/freed by libavcodec.
  795. * - decoding: Set/allocated/freed by user.
  796. */
  797. uint8_t *extradata;
  798. int extradata_size;
  799. /**
  800. * This is the fundamental unit of time (in seconds) in terms
  801. * of which frame timestamps are represented. For fixed-fps content,
  802. * timebase should be 1/framerate and timestamp increments should be
  803. * identically 1.
  804. * - encoding: MUST be set by user.
  805. * - decoding: Set by libavcodec.
  806. */
  807. AVRational time_base;
  808. /* video only */
  809. /**
  810. * picture width / height.
  811. * - encoding: MUST be set by user.
  812. * - decoding: Set by libavcodec.
  813. * Note: For compatibility it is possible to set this instead of
  814. * coded_width/height before decoding.
  815. */
  816. int width, height;
  817. #define FF_ASPECT_EXTENDED 15
  818. /**
  819. * the number of pictures in a group of pictures, or 0 for intra_only
  820. * - encoding: Set by user.
  821. * - decoding: unused
  822. */
  823. int gop_size;
  824. /**
  825. * Pixel format, see PIX_FMT_xxx.
  826. * - encoding: Set by user.
  827. * - decoding: Set by libavcodec.
  828. */
  829. enum PixelFormat pix_fmt;
  830. /**
  831. * Frame rate emulation. If not zero, the lower layer (i.e. format handler)
  832. * has to read frames at native frame rate.
  833. * - encoding: Set by user.
  834. * - decoding: unused
  835. */
  836. int rate_emu;
  837. /**
  838. * If non NULL, 'draw_horiz_band' is called by the libavcodec
  839. * decoder to draw a horizontal band. It improves cache usage. Not
  840. * all codecs can do that. You must check the codec capabilities
  841. * beforehand.
  842. * - encoding: unused
  843. * - decoding: Set by user.
  844. * @param height the height of the slice
  845. * @param y the y position of the slice
  846. * @param type 1->top field, 2->bottom field, 3->frame
  847. * @param offset offset into the AVFrame.data from which the slice should be read
  848. */
  849. void (*draw_horiz_band)(struct AVCodecContext *s,
  850. const AVFrame *src, int offset[4],
  851. int y, int type, int height);
  852. /* audio only */
  853. int sample_rate; ///< samples per second
  854. int channels;
  855. /**
  856. * audio sample format
  857. * - encoding: Set by user.
  858. * - decoding: Set by libavcodec.
  859. */
  860. enum SampleFormat sample_fmt; ///< sample format, currently unused
  861. /* The following data should not be initialized. */
  862. /**
  863. * Samples per packet, initialized when calling 'init'.
  864. */
  865. int frame_size;
  866. int frame_number; ///< audio or video frame number
  867. int real_pict_num; ///< Returns the real picture number of previous encoded frame.
  868. /**
  869. * Number of frames the decoded output will be delayed relative to
  870. * the encoded input.
  871. * - encoding: Set by libavcodec.
  872. * - decoding: unused
  873. */
  874. int delay;
  875. /* - encoding parameters */
  876. float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
  877. float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
  878. /**
  879. * minimum quantizer
  880. * - encoding: Set by user.
  881. * - decoding: unused
  882. */
  883. int qmin;
  884. /**
  885. * maximum quantizer
  886. * - encoding: Set by user.
  887. * - decoding: unused
  888. */
  889. int qmax;
  890. /**
  891. * maximum quantizer difference between frames
  892. * - encoding: Set by user.
  893. * - decoding: unused
  894. */
  895. int max_qdiff;
  896. /**
  897. * maximum number of B-frames between non-B-frames
  898. * Note: The output will be delayed by max_b_frames+1 relative to the input.
  899. * - encoding: Set by user.
  900. * - decoding: unused
  901. */
  902. int max_b_frames;
  903. /**
  904. * qscale factor between IP and B-frames
  905. * - encoding: Set by user.
  906. * - decoding: unused
  907. */
  908. float b_quant_factor;
  909. /** obsolete FIXME remove */
  910. int rc_strategy;
  911. #define FF_RC_STRATEGY_XVID 1
  912. int b_frame_strategy;
  913. /**
  914. * hurry up amount
  915. * - encoding: unused
  916. * - decoding: Set by user. 1-> Skip B-frames, 2-> Skip IDCT/dequant too, 5-> Skip everything except header
  917. * @deprecated Deprecated in favor of skip_idct and skip_frame.
  918. */
  919. int hurry_up;
  920. struct AVCodec *codec;
  921. void *priv_data;
  922. #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
  923. /* unused, FIXME remove*/
  924. int rtp_mode;
  925. #endif
  926. int rtp_payload_size; /* The size of the RTP payload: the coder will */
  927. /* do its best to deliver a chunk with size */
  928. /* below rtp_payload_size, the chunk will start */
  929. /* with a start code on some codecs like H.263. */
  930. /* This doesn't take account of any particular */
  931. /* headers inside the transmitted RTP payload. */
  932. /* The RTP callback: This function is called */
  933. /* every time the encoder has a packet to send. */
  934. /* It depends on the encoder if the data starts */
  935. /* with a Start Code (it should). H.263 does. */
  936. /* mb_nb contains the number of macroblocks */
  937. /* encoded in the RTP payload. */
  938. void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb);
  939. /* statistics, used for 2-pass encoding */
  940. int mv_bits;
  941. int header_bits;
  942. int i_tex_bits;
  943. int p_tex_bits;
  944. int i_count;
  945. int p_count;
  946. int skip_count;
  947. int misc_bits;
  948. /**
  949. * number of bits used for the previously encoded frame
  950. * - encoding: Set by libavcodec.
  951. * - decoding: unused
  952. */
  953. int frame_bits;
  954. /**
  955. * Private data of the user, can be used to carry app specific stuff.
  956. * - encoding: Set by user.
  957. * - decoding: Set by user.
  958. */
  959. void *opaque;
  960. char codec_name[32];
  961. enum CodecType codec_type; /* see CODEC_TYPE_xxx */
  962. enum CodecID codec_id; /* see CODEC_ID_xxx */
  963. /**
  964. * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
  965. * This is used to work around some encoder bugs.
  966. * A demuxer should set this to what is stored in the field used to identify the codec.
  967. * If there are multiple such fields in a container then the demuxer should choose the one
  968. * which maximizes the information about the used codec.
  969. * If the codec tag field in a container is larger then 32 bits then the demuxer should
  970. * remap the longer ID to 32 bits with a table or other structure. Alternatively a new
  971. * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated
  972. * first.
  973. * - encoding: Set by user, if not then the default based on codec_id will be used.
  974. * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
  975. */
  976. unsigned int codec_tag;
  977. /**
  978. * Work around bugs in encoders which sometimes cannot be detected automatically.
  979. * - encoding: Set by user
  980. * - decoding: Set by user
  981. */
  982. int workaround_bugs;
  983. #define FF_BUG_AUTODETECT 1 ///< autodetection
  984. #define FF_BUG_OLD_MSMPEG4 2
  985. #define FF_BUG_XVID_ILACE 4
  986. #define FF_BUG_UMP4 8
  987. #define FF_BUG_NO_PADDING 16
  988. #define FF_BUG_AMV 32
  989. #define FF_BUG_AC_VLC 0 ///< Will be removed, libavcodec can now handle these non-compliant files by default.
  990. #define FF_BUG_QPEL_CHROMA 64
  991. #define FF_BUG_STD_QPEL 128
  992. #define FF_BUG_QPEL_CHROMA2 256
  993. #define FF_BUG_DIRECT_BLOCKSIZE 512
  994. #define FF_BUG_EDGE 1024
  995. #define FF_BUG_HPEL_CHROMA 2048
  996. #define FF_BUG_DC_CLIP 4096
  997. #define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders.
  998. //#define FF_BUG_FAKE_SCALABILITY 16 //Autodetection should work 100%.
  999. /**
  1000. * luma single coefficient elimination threshold
  1001. * - encoding: Set by user.
  1002. * - decoding: unused
  1003. */
  1004. int luma_elim_threshold;
  1005. /**
  1006. * chroma single coeff elimination threshold
  1007. * - encoding: Set by user.
  1008. * - decoding: unused
  1009. */
  1010. int chroma_elim_threshold;
  1011. /**
  1012. * strictly follow the standard (MPEG4, ...).
  1013. * - encoding: Set by user.
  1014. * - decoding: unused
  1015. */
  1016. int strict_std_compliance;
  1017. #define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to a older more strict version of the spec or reference software.
  1018. #define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences.
  1019. #define FF_COMPLIANCE_NORMAL 0
  1020. #define FF_COMPLIANCE_INOFFICIAL -1 ///< Allow inofficial extensions.
  1021. #define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things.
  1022. /**
  1023. * qscale offset between IP and B-frames
  1024. * If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset).
  1025. * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
  1026. * - encoding: Set by user.
  1027. * - decoding: unused
  1028. */
  1029. float b_quant_offset;
  1030. /**
  1031. * Error resilience; higher values will detect more errors but may
  1032. * misdetect some more or less valid parts as errors.
  1033. * - encoding: unused
  1034. * - decoding: Set by user.
  1035. */
  1036. int error_resilience;
  1037. #define FF_ER_CAREFUL 1
  1038. #define FF_ER_COMPLIANT 2
  1039. #define FF_ER_AGGRESSIVE 3
  1040. #define FF_ER_VERY_AGGRESSIVE 4
  1041. /**
  1042. * Called at the beginning of each frame to get a buffer for it.
  1043. * If pic.reference is set then the frame will be read later by libavcodec.
  1044. * avcodec_align_dimensions() should be used to find the required width and
  1045. * height, as they normally need to be rounded up to the next multiple of 16.
  1046. * - encoding: unused
  1047. * - decoding: Set by libavcodec., user can override.
  1048. */
  1049. int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
  1050. /**
  1051. * Called to release buffers which where allocated with get_buffer.
  1052. * A released buffer can be reused in get_buffer().
  1053. * pic.data[*] must be set to NULL.
  1054. * - encoding: unused
  1055. * - decoding: Set by libavcodec., user can override.
  1056. */
  1057. void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
  1058. /**
  1059. * If 1 the stream has a 1 frame delay during decoding.
  1060. * - encoding: Set by libavcodec.
  1061. * - decoding: Set by libavcodec.
  1062. */
  1063. int has_b_frames;
  1064. /**
  1065. * number of bytes per packet if constant and known or 0
  1066. * Used by some WAV based audio codecs.
  1067. */
  1068. int block_align;
  1069. int parse_only; /* - decoding only: If true, only parsing is done
  1070. (function avcodec_parse_frame()). The frame
  1071. data is returned. Only MPEG codecs support this now. */
  1072. /**
  1073. * 0-> h263 quant 1-> mpeg quant
  1074. * - encoding: Set by user.
  1075. * - decoding: unused
  1076. */
  1077. int mpeg_quant;
  1078. /**
  1079. * pass1 encoding statistics output buffer
  1080. * - encoding: Set by libavcodec.
  1081. * - decoding: unused
  1082. */
  1083. char *stats_out;
  1084. /**
  1085. * pass2 encoding statistics input buffer
  1086. * Concatenated stuff from stats_out of pass1 should be placed here.
  1087. * - encoding: Allocated/set/freed by user.
  1088. * - decoding: unused
  1089. */
  1090. char *stats_in;
  1091. /**
  1092. * ratecontrol qmin qmax limiting method
  1093. * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax.
  1094. * - encoding: Set by user.
  1095. * - decoding: unused
  1096. */
  1097. float rc_qsquish;
  1098. float rc_qmod_amp;
  1099. int rc_qmod_freq;
  1100. /**
  1101. * ratecontrol override, see RcOverride
  1102. * - encoding: Allocated/set/freed by user.
  1103. * - decoding: unused
  1104. */
  1105. RcOverride *rc_override;
  1106. int rc_override_count;
  1107. /**
  1108. * rate control equation
  1109. * - encoding: Set by user
  1110. * - decoding: unused
  1111. */
  1112. const char *rc_eq;
  1113. /**
  1114. * maximum bitrate
  1115. * - encoding: Set by user.
  1116. * - decoding: unused
  1117. */
  1118. int rc_max_rate;
  1119. /**
  1120. * minimum bitrate
  1121. * - encoding: Set by user.
  1122. * - decoding: unused
  1123. */
  1124. int rc_min_rate;
  1125. /**
  1126. * decoder bitstream buffer size
  1127. * - encoding: Set by user.
  1128. * - decoding: unused
  1129. */
  1130. int rc_buffer_size;
  1131. float rc_buffer_aggressivity;
  1132. /**
  1133. * qscale factor between P and I-frames
  1134. * If > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset).
  1135. * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
  1136. * - encoding: Set by user.
  1137. * - decoding: unused
  1138. */
  1139. float i_quant_factor;
  1140. /**
  1141. * qscale offset between P and I-frames
  1142. * - encoding: Set by user.
  1143. * - decoding: unused
  1144. */
  1145. float i_quant_offset;
  1146. /**
  1147. * initial complexity for pass1 ratecontrol
  1148. * - encoding: Set by user.
  1149. * - decoding: unused
  1150. */
  1151. float rc_initial_cplx;
  1152. /**
  1153. * DCT algorithm, see FF_DCT_* below
  1154. * - encoding: Set by user.
  1155. * - decoding: unused
  1156. */
  1157. int dct_algo;
  1158. #define FF_DCT_AUTO 0
  1159. #define FF_DCT_FASTINT 1
  1160. #define FF_DCT_INT 2
  1161. #define FF_DCT_MMX 3
  1162. #define FF_DCT_MLIB 4
  1163. #define FF_DCT_ALTIVEC 5
  1164. #define FF_DCT_FAAN 6
  1165. /**
  1166. * luminance masking (0-> disabled)
  1167. * - encoding: Set by user.
  1168. * - decoding: unused
  1169. */
  1170. float lumi_masking;
  1171. /**
  1172. * temporary complexity masking (0-> disabled)
  1173. * - encoding: Set by user.
  1174. * - decoding: unused
  1175. */
  1176. float temporal_cplx_masking;
  1177. /**
  1178. * spatial complexity masking (0-> disabled)
  1179. * - encoding: Set by user.
  1180. * - decoding: unused
  1181. */
  1182. float spatial_cplx_masking;
  1183. /**
  1184. * p block masking (0-> disabled)
  1185. * - encoding: Set by user.
  1186. * - decoding: unused
  1187. */
  1188. float p_masking;
  1189. /**
  1190. * darkness masking (0-> disabled)
  1191. * - encoding: Set by user.
  1192. * - decoding: unused
  1193. */
  1194. float dark_masking;
  1195. #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
  1196. /* for binary compatibility */
  1197. int unused;
  1198. #endif
  1199. /**
  1200. * IDCT algorithm, see FF_IDCT_* below.
  1201. * - encoding: Set by user.
  1202. * - decoding: Set by user.
  1203. */
  1204. int idct_algo;
  1205. #define FF_IDCT_AUTO 0
  1206. #define FF_IDCT_INT 1
  1207. #define FF_IDCT_SIMPLE 2
  1208. #define FF_IDCT_SIMPLEMMX 3
  1209. #define FF_IDCT_LIBMPEG2MMX 4
  1210. #define FF_IDCT_PS2 5
  1211. #define FF_IDCT_MLIB 6
  1212. #define FF_IDCT_ARM 7
  1213. #define FF_IDCT_ALTIVEC 8
  1214. #define FF_IDCT_SH4 9
  1215. #define FF_IDCT_SIMPLEARM 10
  1216. #define FF_IDCT_H264 11
  1217. #define FF_IDCT_VP3 12
  1218. #define FF_IDCT_IPP 13
  1219. #define FF_IDCT_XVIDMMX 14
  1220. #define FF_IDCT_CAVS 15
  1221. #define FF_IDCT_SIMPLEARMV5TE 16
  1222. #define FF_IDCT_SIMPLEARMV6 17
  1223. #define FF_IDCT_SIMPLEVIS 18
  1224. #define FF_IDCT_WMV2 19
  1225. #define FF_IDCT_FAAN 20
  1226. /**
  1227. * slice count
  1228. * - encoding: Set by libavcodec.
  1229. * - decoding: Set by user (or 0).
  1230. */
  1231. int slice_count;
  1232. /**
  1233. * slice offsets in the frame in bytes
  1234. * - encoding: Set/allocated by libavcodec.
  1235. * - decoding: Set/allocated by user (or NULL).
  1236. */
  1237. int *slice_offset;
  1238. /**
  1239. * error concealment flags
  1240. * - encoding: unused
  1241. * - decoding: Set by user.
  1242. */
  1243. int error_concealment;
  1244. #define FF_EC_GUESS_MVS 1
  1245. #define FF_EC_DEBLOCK 2
  1246. /**
  1247. * dsp_mask could be add used to disable unwanted CPU features
  1248. * CPU features (i.e. MMX, SSE. ...)
  1249. *
  1250. * With the FORCE flag you may instead enable given CPU features.
  1251. * (Dangerous: Usable in case of misdetection, improper usage however will
  1252. * result into program crash.)
  1253. */
  1254. unsigned dsp_mask;
  1255. #define FF_MM_FORCE 0x80000000 /* Force usage of selected flags (OR) */
  1256. /* lower 16 bits - CPU features */
  1257. #define FF_MM_MMX 0x0001 ///< standard MMX
  1258. #define FF_MM_3DNOW 0x0004 ///< AMD 3DNOW
  1259. #define FF_MM_MMXEXT 0x0002 ///< SSE integer functions or AMD MMX ext
  1260. #define FF_MM_SSE 0x0008 ///< SSE functions
  1261. #define FF_MM_SSE2 0x0010 ///< PIV SSE2 functions
  1262. #define FF_MM_3DNOWEXT 0x0020 ///< AMD 3DNowExt
  1263. #define FF_MM_SSE3 0x0040 ///< Prescott SSE3 functions
  1264. #define FF_MM_SSSE3 0x0080 ///< Conroe SSSE3 functions
  1265. #define FF_MM_IWMMXT 0x0100 ///< XScale IWMMXT
  1266. /**
  1267. * bits per sample/pixel from the demuxer (needed for huffyuv).
  1268. * - encoding: Set by libavcodec.
  1269. * - decoding: Set by user.
  1270. */
  1271. int bits_per_sample;
  1272. /**
  1273. * prediction method (needed for huffyuv)
  1274. * - encoding: Set by user.
  1275. * - decoding: unused
  1276. */
  1277. int prediction_method;
  1278. #define FF_PRED_LEFT 0
  1279. #define FF_PRED_PLANE 1
  1280. #define FF_PRED_MEDIAN 2
  1281. /**
  1282. * sample aspect ratio (0 if unknown)
  1283. * Numerator and denominator must be relatively prime and smaller than 256 for some video standards.
  1284. * - encoding: Set by user.
  1285. * - decoding: Set by libavcodec.
  1286. */
  1287. AVRational sample_aspect_ratio;
  1288. /**
  1289. * the picture in the bitstream
  1290. * - encoding: Set by libavcodec.
  1291. * - decoding: Set by libavcodec.
  1292. */
  1293. AVFrame *coded_frame;
  1294. /**
  1295. * debug
  1296. * - encoding: Set by user.
  1297. * - decoding: Set by user.
  1298. */
  1299. int debug;
  1300. #define FF_DEBUG_PICT_INFO 1
  1301. #define FF_DEBUG_RC 2
  1302. #define FF_DEBUG_BITSTREAM 4
  1303. #define FF_DEBUG_MB_TYPE 8
  1304. #define FF_DEBUG_QP 16
  1305. #define FF_DEBUG_MV 32
  1306. #define FF_DEBUG_DCT_COEFF 0x00000040
  1307. #define FF_DEBUG_SKIP 0x00000080
  1308. #define FF_DEBUG_STARTCODE 0x00000100
  1309. #define FF_DEBUG_PTS 0x00000200
  1310. #define FF_DEBUG_ER 0x00000400
  1311. #define FF_DEBUG_MMCO 0x00000800
  1312. #define FF_DEBUG_BUGS 0x00001000
  1313. #define FF_DEBUG_VIS_QP 0x00002000
  1314. #define FF_DEBUG_VIS_MB_TYPE 0x00004000
  1315. /**
  1316. * debug
  1317. * - encoding: Set by user.
  1318. * - decoding: Set by user.
  1319. */
  1320. int debug_mv;
  1321. #define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames
  1322. #define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames
  1323. #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames
  1324. /**
  1325. * error
  1326. * - encoding: Set by libavcodec if flags&CODEC_FLAG_PSNR.
  1327. * - decoding: unused
  1328. */
  1329. uint64_t error[4];
  1330. /**
  1331. * minimum MB quantizer
  1332. * - encoding: unused
  1333. * - decoding: unused
  1334. */
  1335. int mb_qmin;
  1336. /**
  1337. * maximum MB quantizer
  1338. * - encoding: unused
  1339. * - decoding: unused
  1340. */
  1341. int mb_qmax;
  1342. /**
  1343. * motion estimation comparison function
  1344. * - encoding: Set by user.
  1345. * - decoding: unused
  1346. */
  1347. int me_cmp;
  1348. /**
  1349. * subpixel motion estimation comparison function
  1350. * - encoding: Set by user.
  1351. * - decoding: unused
  1352. */
  1353. int me_sub_cmp;
  1354. /**
  1355. * macroblock comparison function (not supported yet)
  1356. * - encoding: Set by user.
  1357. * - decoding: unused
  1358. */
  1359. int mb_cmp;
  1360. /**
  1361. * interlaced DCT comparison function
  1362. * - encoding: Set by user.
  1363. * - decoding: unused
  1364. */
  1365. int ildct_cmp;
  1366. #define FF_CMP_SAD 0
  1367. #define FF_CMP_SSE 1
  1368. #define FF_CMP_SATD 2
  1369. #define FF_CMP_DCT 3
  1370. #define FF_CMP_PSNR 4
  1371. #define FF_CMP_BIT 5
  1372. #define FF_CMP_RD 6
  1373. #define FF_CMP_ZERO 7
  1374. #define FF_CMP_VSAD 8
  1375. #define FF_CMP_VSSE 9
  1376. #define FF_CMP_NSSE 10
  1377. #define FF_CMP_W53 11
  1378. #define FF_CMP_W97 12
  1379. #define FF_CMP_DCTMAX 13
  1380. #define FF_CMP_DCT264 14
  1381. #define FF_CMP_CHROMA 256
  1382. /**
  1383. * ME diamond size & shape
  1384. * - encoding: Set by user.
  1385. * - decoding: unused
  1386. */
  1387. int dia_size;
  1388. /**
  1389. * amount of previous MV predictors (2a+1 x 2a+1 square)
  1390. * - encoding: Set by user.
  1391. * - decoding: unused
  1392. */
  1393. int last_predictor_count;
  1394. /**
  1395. * prepass for motion estimation
  1396. * - encoding: Set by user.
  1397. * - decoding: unused
  1398. */
  1399. int pre_me;
  1400. /**
  1401. * motion estimation prepass comparison function
  1402. * - encoding: Set by user.
  1403. * - decoding: unused
  1404. */
  1405. int me_pre_cmp;
  1406. /**
  1407. * ME prepass diamond size & shape
  1408. * - encoding: Set by user.
  1409. * - decoding: unused
  1410. */
  1411. int pre_dia_size;
  1412. /**
  1413. * subpel ME quality
  1414. * - encoding: Set by user.
  1415. * - decoding: unused
  1416. */
  1417. int me_subpel_quality;
  1418. /**
  1419. * callback to negotiate the pixelFormat
  1420. * @param fmt is the list of formats which are supported by the codec,
  1421. * it is terminated by -1 as 0 is a valid format, the formats are ordered by quality.
  1422. * The first is always the native one.
  1423. * @return the chosen format
  1424. * - encoding: unused
  1425. * - decoding: Set by user, if not set the native format will be chosen.
  1426. */
  1427. enum PixelFormat (*get_format)(struct AVCodecContext *s, const enum PixelFormat * fmt);
  1428. /**
  1429. * DTG active format information (additional aspect ratio
  1430. * information only used in DVB MPEG-2 transport streams)
  1431. * 0 if not set.
  1432. *
  1433. * - encoding: unused
  1434. * - decoding: Set by decoder.
  1435. */
  1436. int dtg_active_format;
  1437. #define FF_DTG_AFD_SAME 8
  1438. #define FF_DTG_AFD_4_3 9
  1439. #define FF_DTG_AFD_16_9 10
  1440. #define FF_DTG_AFD_14_9 11
  1441. #define FF_DTG_AFD_4_3_SP_14_9 13
  1442. #define FF_DTG_AFD_16_9_SP_14_9 14
  1443. #define FF_DTG_AFD_SP_4_3 15
  1444. /**
  1445. * maximum motion estimation search range in subpel units
  1446. * If 0 then no limit.
  1447. *
  1448. * - encoding: Set by user.
  1449. * - decoding: unused
  1450. */
  1451. int me_range;
  1452. /**
  1453. * intra quantizer bias
  1454. * - encoding: Set by user.
  1455. * - decoding: unused
  1456. */
  1457. int intra_quant_bias;
  1458. #define FF_DEFAULT_QUANT_BIAS 999999
  1459. /**
  1460. * inter quantizer bias
  1461. * - encoding: Set by user.
  1462. * - decoding: unused
  1463. */
  1464. int inter_quant_bias;
  1465. /**
  1466. * color table ID
  1467. * - encoding: unused
  1468. * - decoding: Which clrtable should be used for 8bit RGB images.
  1469. * Tables have to be stored somewhere. FIXME
  1470. */
  1471. int color_table_id;
  1472. /**
  1473. * internal_buffer count
  1474. * Don't touch, used by libavcodec default_get_buffer().
  1475. */
  1476. int internal_buffer_count;
  1477. /**
  1478. * internal_buffers
  1479. * Don't touch, used by libavcodec default_get_buffer().
  1480. */
  1481. void *internal_buffer;
  1482. #define FF_LAMBDA_SHIFT 7
  1483. #define FF_LAMBDA_SCALE (1<<FF_LAMBDA_SHIFT)
  1484. #define FF_QP2LAMBDA 118 ///< factor to convert from H.263 QP to lambda
  1485. #define FF_LAMBDA_MAX (256*128-1)
  1486. #define FF_QUALITY_SCALE FF_LAMBDA_SCALE //FIXME maybe remove
  1487. /**
  1488. * Global quality for codecs which cannot change it per frame.
  1489. * This should be proportional to MPEG-1/2/4 qscale.
  1490. * - encoding: Set by user.
  1491. * - decoding: unused
  1492. */
  1493. int global_quality;
  1494. #define FF_CODER_TYPE_VLC 0
  1495. #define FF_CODER_TYPE_AC 1
  1496. #define FF_CODER_TYPE_RAW 2
  1497. #define FF_CODER_TYPE_RLE 3
  1498. #define FF_CODER_TYPE_DEFLATE 4
  1499. /**
  1500. * coder type
  1501. * - encoding: Set by user.
  1502. * - decoding: unused
  1503. */
  1504. int coder_type;
  1505. /**
  1506. * context model
  1507. * - encoding: Set by user.
  1508. * - decoding: unused
  1509. */
  1510. int context_model;
  1511. #if 0
  1512. /**
  1513. *
  1514. * - encoding: unused
  1515. * - decoding: Set by user.
  1516. */
  1517. uint8_t * (*realloc)(struct AVCodecContext *s, uint8_t *buf, int buf_size);
  1518. #endif
  1519. /**
  1520. * slice flags
  1521. * - encoding: unused
  1522. * - decoding: Set by user.
  1523. */
  1524. int slice_flags;
  1525. #define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display
  1526. #define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
  1527. #define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
  1528. /**
  1529. * XVideo Motion Acceleration
  1530. * - encoding: forbidden
  1531. * - decoding: set by decoder
  1532. */
  1533. int xvmc_acceleration;
  1534. /**
  1535. * macroblock decision mode
  1536. * - encoding: Set by user.
  1537. * - decoding: unused
  1538. */
  1539. int mb_decision;
  1540. #define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp
  1541. #define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits
  1542. #define FF_MB_DECISION_RD 2 ///< rate distoration
  1543. /**
  1544. * custom intra quantization matrix
  1545. * - encoding: Set by user, can be NULL.
  1546. * - decoding: Set by libavcodec.
  1547. */
  1548. uint16_t *intra_matrix;
  1549. /**
  1550. * custom inter quantization matrix
  1551. * - encoding: Set by user, can be NULL.
  1552. * - decoding: Set by libavcodec.
  1553. */
  1554. uint16_t *inter_matrix;
  1555. /**
  1556. * fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
  1557. * This is used to work around some encoder bugs.
  1558. * - encoding: unused
  1559. * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
  1560. */
  1561. unsigned int stream_codec_tag;
  1562. /**
  1563. * scene change detection threshold
  1564. * 0 is default, larger means fewer detected scene changes.
  1565. * - encoding: Set by user.
  1566. * - decoding: unused
  1567. */
  1568. int scenechange_threshold;
  1569. /**
  1570. * minimum Lagrange multipler
  1571. * - encoding: Set by user.
  1572. * - decoding: unused
  1573. */
  1574. int lmin;
  1575. /**
  1576. * maximum Lagrange multipler
  1577. * - encoding: Set by user.
  1578. * - decoding: unused
  1579. */
  1580. int lmax;
  1581. /**
  1582. * palette control structure
  1583. * - encoding: ??? (no palette-enabled encoder yet)
  1584. * - decoding: Set by user.
  1585. */
  1586. struct AVPaletteControl *palctrl;
  1587. /**
  1588. * noise reduction strength
  1589. * - encoding: Set by user.
  1590. * - decoding: unused
  1591. */
  1592. int noise_reduction;
  1593. /**
  1594. * Called at the beginning of a frame to get cr buffer for it.
  1595. * Buffer type (size, hints) must be the same. libavcodec won't check it.
  1596. * libavcodec will pass previous buffer in pic, function should return
  1597. * same buffer or new buffer with old frame "painted" into it.
  1598. * If pic.data[0] == NULL must behave like get_buffer().
  1599. * - encoding: unused
  1600. * - decoding: Set by libavcodec., user can override
  1601. */
  1602. int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic);
  1603. /**
  1604. * Number of bits which should be loaded into the rc buffer before decoding starts.
  1605. * - encoding: Set by user.
  1606. * - decoding: unused
  1607. */
  1608. int rc_initial_buffer_occupancy;
  1609. /**
  1610. *
  1611. * - encoding: Set by user.
  1612. * - decoding: unused
  1613. */
  1614. int inter_threshold;
  1615. /**
  1616. * CODEC_FLAG2_*
  1617. * - encoding: Set by user.
  1618. * - decoding: Set by user.
  1619. */
  1620. int flags2;
  1621. /**
  1622. * Simulates errors in the bitstream to test error concealment.
  1623. * - encoding: Set by user.
  1624. * - decoding: unused
  1625. */
  1626. int error_rate;
  1627. /**
  1628. * MP3 antialias algorithm, see FF_AA_* below.
  1629. * - encoding: unused
  1630. * - decoding: Set by user.
  1631. */
  1632. int antialias_algo;
  1633. #define FF_AA_AUTO 0
  1634. #define FF_AA_FASTINT 1 //not implemented yet
  1635. #define FF_AA_INT 2
  1636. #define FF_AA_FLOAT 3
  1637. /**
  1638. * quantizer noise shaping
  1639. * - encoding: Set by user.
  1640. * - decoding: unused
  1641. */
  1642. int quantizer_noise_shaping;
  1643. /**
  1644. * thread count
  1645. * is used to decide how many independent tasks should be passed to execute()
  1646. * - encoding: Set by user.
  1647. * - decoding: Set by user.
  1648. */
  1649. int thread_count;
  1650. /**
  1651. * The codec may call this to execute several independent things.
  1652. * It will return only after finishing all tasks.
  1653. * The user may replace this with some multithreaded implementation,
  1654. * the default implementation will execute the parts serially.
  1655. * @param count the number of things to execute
  1656. * - encoding: Set by libavcodec, user can override.
  1657. * - decoding: Set by libavcodec, user can override.
  1658. */
  1659. int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void **arg2, int *ret, int count);
  1660. /**
  1661. * thread opaque
  1662. * Can be used by execute() to store some per AVCodecContext stuff.
  1663. * - encoding: set by execute()
  1664. * - decoding: set by execute()
  1665. */
  1666. void *thread_opaque;
  1667. /**
  1668. * Motion estimation threshold below which no motion estimation is
  1669. * performed, but instead the user specified motion vectors are used.
  1670. *
  1671. * - encoding: Set by user.
  1672. * - decoding: unused
  1673. */
  1674. int me_threshold;
  1675. /**
  1676. * Macroblock threshold below which the user specified macroblock types will be used.
  1677. * - encoding: Set by user.
  1678. * - decoding: unused
  1679. */
  1680. int mb_threshold;
  1681. /**
  1682. * precision of the intra DC coefficient - 8
  1683. * - encoding: Set by user.
  1684. * - decoding: unused
  1685. */
  1686. int intra_dc_precision;
  1687. /**
  1688. * noise vs. sse weight for the nsse comparsion function
  1689. * - encoding: Set by user.
  1690. * - decoding: unused
  1691. */
  1692. int nsse_weight;
  1693. /**
  1694. * Number of macroblock rows at the top which are skipped.
  1695. * - encoding: unused
  1696. * - decoding: Set by user.
  1697. */
  1698. int skip_top;
  1699. /**
  1700. * Number of macroblock rows at the bottom which are skipped.
  1701. * - encoding: unused
  1702. * - decoding: Set by user.
  1703. */
  1704. int skip_bottom;
  1705. /**
  1706. * profile
  1707. * - encoding: Set by user.
  1708. * - decoding: Set by libavcodec.
  1709. */
  1710. int profile;
  1711. #define FF_PROFILE_UNKNOWN -99
  1712. #define FF_PROFILE_AAC_MAIN 0
  1713. #define FF_PROFILE_AAC_LOW 1
  1714. #define FF_PROFILE_AAC_SSR 2
  1715. #define FF_PROFILE_AAC_LTP 3
  1716. /**
  1717. * level
  1718. * - encoding: Set by user.
  1719. * - decoding: Set by libavcodec.
  1720. */
  1721. int level;
  1722. #define FF_LEVEL_UNKNOWN -99
  1723. /**
  1724. * low resolution decoding, 1-> 1/2 size, 2->1/4 size
  1725. * - encoding: unused
  1726. * - decoding: Set by user.
  1727. */
  1728. int lowres;
  1729. /**
  1730. * Bitstream width / height, may be different from width/height if lowres
  1731. * or other things are used.
  1732. * - encoding: unused
  1733. * - decoding: Set by user before init if known. Codec should override / dynamically change if needed.
  1734. */
  1735. int coded_width, coded_height;
  1736. /**
  1737. * frame skip threshold
  1738. * - encoding: Set by user.
  1739. * - decoding: unused
  1740. */
  1741. int frame_skip_threshold;
  1742. /**
  1743. * frame skip factor
  1744. * - encoding: Set by user.
  1745. * - decoding: unused
  1746. */
  1747. int frame_skip_factor;
  1748. /**
  1749. * frame skip exponent
  1750. * - encoding: Set by user.
  1751. * - decoding: unused
  1752. */
  1753. int frame_skip_exp;
  1754. /**
  1755. * frame skip comparison function
  1756. * - encoding: Set by user.
  1757. * - decoding: unused
  1758. */
  1759. int frame_skip_cmp;
  1760. /**
  1761. * Border processing masking, raises the quantizer for mbs on the borders
  1762. * of the picture.
  1763. * - encoding: Set by user.
  1764. * - decoding: unused
  1765. */
  1766. float border_masking;
  1767. /**
  1768. * minimum MB lagrange multipler
  1769. * - encoding: Set by user.
  1770. * - decoding: unused
  1771. */
  1772. int mb_lmin;
  1773. /**
  1774. * maximum MB lagrange multipler
  1775. * - encoding: Set by user.
  1776. * - decoding: unused
  1777. */
  1778. int mb_lmax;
  1779. /**
  1780. *
  1781. * - encoding: Set by user.
  1782. * - decoding: unused
  1783. */
  1784. int me_penalty_compensation;
  1785. /**
  1786. *
  1787. * - encoding: unused
  1788. * - decoding: Set by user.
  1789. */
  1790. enum AVDiscard skip_loop_filter;
  1791. /**
  1792. *
  1793. * - encoding: unused
  1794. * - decoding: Set by user.
  1795. */
  1796. enum AVDiscard skip_idct;
  1797. /**
  1798. *
  1799. * - encoding: unused
  1800. * - decoding: Set by user.
  1801. */
  1802. enum AVDiscard skip_frame;
  1803. /**
  1804. *
  1805. * - encoding: Set by user.
  1806. * - decoding: unused
  1807. */
  1808. int bidir_refine;
  1809. /**
  1810. *
  1811. * - encoding: Set by user.
  1812. * - decoding: unused
  1813. */
  1814. int brd_scale;
  1815. /**
  1816. * constant rate factor - quality-based VBR - values ~correspond to qps
  1817. * - encoding: Set by user.
  1818. * - decoding: unused
  1819. */
  1820. float crf;
  1821. /**
  1822. * constant quantization parameter rate control method
  1823. * - encoding: Set by user.
  1824. * - decoding: unused
  1825. */
  1826. int cqp;
  1827. /**
  1828. * minimum GOP size
  1829. * - encoding: Set by user.
  1830. * - decoding: unused
  1831. */
  1832. int keyint_min;
  1833. /**
  1834. * number of reference frames
  1835. * - encoding: Set by user.
  1836. * - decoding: unused
  1837. */
  1838. int refs;
  1839. /**
  1840. * chroma qp offset from luma
  1841. * - encoding: Set by user.
  1842. * - decoding: unused
  1843. */
  1844. int chromaoffset;
  1845. /**
  1846. * Influences how often B-frames are used.
  1847. * - encoding: Set by user.
  1848. * - decoding: unused
  1849. */
  1850. int bframebias;
  1851. /**
  1852. * trellis RD quantization
  1853. * - encoding: Set by user.
  1854. * - decoding: unused
  1855. */
  1856. int trellis;
  1857. /**
  1858. * Reduce fluctuations in qp (before curve compression).
  1859. * - encoding: Set by user.
  1860. * - decoding: unused
  1861. */
  1862. float complexityblur;
  1863. /**
  1864. * in-loop deblocking filter alphac0 parameter
  1865. * alpha is in the range -6...6
  1866. * - encoding: Set by user.
  1867. * - decoding: unused
  1868. */
  1869. int deblockalpha;
  1870. /**
  1871. * in-loop deblocking filter beta parameter
  1872. * beta is in the range -6...6
  1873. * - encoding: Set by user.
  1874. * - decoding: unused
  1875. */
  1876. int deblockbeta;
  1877. /**
  1878. * macroblock subpartition sizes to consider - p8x8, p4x4, b8x8, i8x8, i4x4
  1879. * - encoding: Set by user.
  1880. * - decoding: unused
  1881. */
  1882. int partitions;
  1883. #define X264_PART_I4X4 0x001 /* Analyze i4x4 */
  1884. #define X264_PART_I8X8 0x002 /* Analyze i8x8 (requires 8x8 transform) */
  1885. #define X264_PART_P8X8 0x010 /* Analyze p16x8, p8x16 and p8x8 */
  1886. #define X264_PART_P4X4 0x020 /* Analyze p8x4, p4x8, p4x4 */
  1887. #define X264_PART_B8X8 0x100 /* Analyze b16x8, b8x16 and b8x8 */
  1888. /**
  1889. * direct MV prediction mode - 0 (none), 1 (spatial), 2 (temporal)
  1890. * - encoding: Set by user.
  1891. * - decoding: unused
  1892. */
  1893. int directpred;
  1894. /**
  1895. * Audio cutoff bandwidth (0 means "automatic")
  1896. * - encoding: Set by user.
  1897. * - decoding: unused
  1898. */
  1899. int cutoff;
  1900. /**
  1901. * Multiplied by qscale for each frame and added to scene_change_score.
  1902. * - encoding: Set by user.
  1903. * - decoding: unused
  1904. */
  1905. int scenechange_factor;
  1906. /**
  1907. *
  1908. * Note: Value depends upon the compare function used for fullpel ME.
  1909. * - encoding: Set by user.
  1910. * - decoding: unused
  1911. */
  1912. int mv0_threshold;
  1913. /**
  1914. * Adjusts sensitivity of b_frame_strategy 1.
  1915. * - encoding: Set by user.
  1916. * - decoding: unused
  1917. */
  1918. int b_sensitivity;
  1919. /**
  1920. * - encoding: Set by user.
  1921. * - decoding: unused
  1922. */
  1923. int compression_level;
  1924. #define FF_COMPRESSION_DEFAULT -1
  1925. /**
  1926. * Sets whether to use LPC mode - used by FLAC encoder.
  1927. * - encoding: Set by user.
  1928. * - decoding: unused
  1929. */
  1930. int use_lpc;
  1931. /**
  1932. * LPC coefficient precision - used by FLAC encoder
  1933. * - encoding: Set by user.
  1934. * - decoding: unused
  1935. */
  1936. int lpc_coeff_precision;
  1937. /**
  1938. * - encoding: Set by user.
  1939. * - decoding: unused
  1940. */
  1941. int min_prediction_order;
  1942. /**
  1943. * - encoding: Set by user.
  1944. * - decoding: unused
  1945. */
  1946. int max_prediction_order;
  1947. /**
  1948. * search method for selecting prediction order
  1949. * - encoding: Set by user.
  1950. * - decoding: unused
  1951. */
  1952. int prediction_order_method;
  1953. /**
  1954. * - encoding: Set by user.
  1955. * - decoding: unused
  1956. */
  1957. int min_partition_order;
  1958. /**
  1959. * - encoding: Set by user.
  1960. * - decoding: unused
  1961. */
  1962. int max_partition_order;
  1963. /**
  1964. * GOP timecode frame start number, in non drop frame format
  1965. * - encoding: Set by user.
  1966. * - decoding: unused
  1967. */
  1968. int64_t timecode_frame_start;
  1969. /**
  1970. * Decoder should decode to this many channels if it can (0 for default)
  1971. * - encoding: unused
  1972. * - decoding: Set by user.
  1973. */
  1974. int request_channels;
  1975. /**
  1976. * Percentage of dynamic range compression to be applied by the decoder.
  1977. * The default value is 1.0, corresponding to full compression.
  1978. * - encoding: unused
  1979. * - decoding: Set by user.
  1980. */
  1981. float drc_scale;
  1982. } AVCodecContext;
  1983. /**
  1984. * AVCodec.
  1985. */
  1986. typedef struct AVCodec {
  1987. /**
  1988. * Name of the codec implementation.
  1989. * The name is globally unique among encoders and among decoders (but an
  1990. * encoder and a decoder can share the same name).
  1991. * This is the primary way to find a codec from the user perspective.
  1992. */
  1993. const char *name;
  1994. enum CodecType type;
  1995. enum CodecID id;
  1996. int priv_data_size;
  1997. int (*init)(AVCodecContext *);
  1998. int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
  1999. int (*close)(AVCodecContext *);
  2000. int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
  2001. const uint8_t *buf, int buf_size);
  2002. int capabilities;
  2003. struct AVCodec *next;
  2004. void (*flush)(AVCodecContext *);
  2005. const AVRational *supported_framerates; ///array of supported framerates, or NULL if any, array is terminated by {0,0}
  2006. const enum PixelFormat *pix_fmts; ///array of supported pixel formats, or NULL if unknown, array is terminanted by -1
  2007. } AVCodec;
  2008. /**
  2009. * four components are given, that's all.
  2010. * the last component is alpha
  2011. */
  2012. typedef struct AVPicture {
  2013. uint8_t *data[4];
  2014. int linesize[4]; ///< number of bytes per line
  2015. } AVPicture;
  2016. /**
  2017. * AVPaletteControl
  2018. * This structure defines a method for communicating palette changes
  2019. * between and demuxer and a decoder.
  2020. *
  2021. * @deprecated Use AVPacket to send palette changes instead.
  2022. * This is totally broken.
  2023. */
  2024. #define AVPALETTE_SIZE 1024
  2025. #define AVPALETTE_COUNT 256
  2026. typedef struct AVPaletteControl {
  2027. /* Demuxer sets this to 1 to indicate the palette has changed;
  2028. * decoder resets to 0. */
  2029. int palette_changed;
  2030. /* 4-byte ARGB palette entries, stored in native byte order; note that
  2031. * the individual palette components should be on a 8-bit scale; if
  2032. * the palette data comes from an IBM VGA native format, the component
  2033. * data is probably 6 bits in size and needs to be scaled. */
  2034. unsigned int palette[AVPALETTE_COUNT];
  2035. } AVPaletteControl attribute_deprecated;
  2036. typedef struct AVSubtitleRect {
  2037. uint16_t x;
  2038. uint16_t y;
  2039. uint16_t w;
  2040. uint16_t h;
  2041. uint16_t nb_colors;
  2042. int linesize;
  2043. uint32_t *rgba_palette;
  2044. uint8_t *bitmap;
  2045. } AVSubtitleRect;
  2046. typedef struct AVSubtitle {
  2047. uint16_t format; /* 0 = graphics */
  2048. uint32_t start_display_time; /* relative to packet pts, in ms */
  2049. uint32_t end_display_time; /* relative to packet pts, in ms */
  2050. uint32_t num_rects;
  2051. AVSubtitleRect *rects;
  2052. } AVSubtitle;
  2053. /* resample.c */
  2054. struct ReSampleContext;
  2055. struct AVResampleContext;
  2056. typedef struct ReSampleContext ReSampleContext;
  2057. ReSampleContext *audio_resample_init(int output_channels, int input_channels,
  2058. int output_rate, int input_rate);
  2059. int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
  2060. void audio_resample_close(ReSampleContext *s);
  2061. struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff);
  2062. int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx);
  2063. void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance);
  2064. void av_resample_close(struct AVResampleContext *c);
  2065. #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
  2066. /* YUV420 format is assumed ! */
  2067. /**
  2068. * @deprecated Use the software scaler (swscale) instead.
  2069. */
  2070. typedef struct ImgReSampleContext ImgReSampleContext attribute_deprecated;
  2071. /**
  2072. * @deprecated Use the software scaler (swscale) instead.
  2073. */
  2074. attribute_deprecated ImgReSampleContext *img_resample_init(int output_width, int output_height,
  2075. int input_width, int input_height);
  2076. /**
  2077. * @deprecated Use the software scaler (swscale) instead.
  2078. */
  2079. attribute_deprecated ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
  2080. int iwidth, int iheight,
  2081. int topBand, int bottomBand,
  2082. int leftBand, int rightBand,
  2083. int padtop, int padbottom,
  2084. int padleft, int padright);
  2085. /**
  2086. * @deprecated Use the software scaler (swscale) instead.
  2087. */
  2088. attribute_deprecated void img_resample(struct ImgReSampleContext *s,
  2089. AVPicture *output, const AVPicture *input);
  2090. /**
  2091. * @deprecated Use the software scaler (swscale) instead.
  2092. */
  2093. attribute_deprecated void img_resample_close(struct ImgReSampleContext *s);
  2094. #endif
  2095. /**
  2096. * Allocate memory for a picture. Call avpicture_free to free it.
  2097. *
  2098. * @param picture the picture to be filled in
  2099. * @param pix_fmt the format of the picture
  2100. * @param width the width of the picture
  2101. * @param height the height of the picture
  2102. * @return zero if successful, a negative value if not
  2103. */
  2104. int avpicture_alloc(AVPicture *picture, int pix_fmt, int width, int height);
  2105. /**
  2106. * Free a picture previously allocated by avpicture_alloc().
  2107. *
  2108. * @param picture the AVPicture to be freed
  2109. */
  2110. void avpicture_free(AVPicture *picture);
  2111. /**
  2112. * Fill in the AVPicture fields.
  2113. * The fields of the given AVPicture are filled in by using the 'ptr' address
  2114. * which points to the image data buffer. Depending on the specified picture
  2115. * format, one or multiple image data pointers and line sizes will be set.
  2116. * If a planar format is specified, several pointers will be set pointing to
  2117. * the different picture planes and the line sizes of the different planes
  2118. * will be stored in the lines_sizes array.
  2119. *
  2120. * @param picture AVPicture whose fields are to be filled in
  2121. * @param ptr Buffer which will contain or contains the actual image data
  2122. * @param pix_fmt The format in which the picture data is stored.
  2123. * @param width the width of the image in pixels
  2124. * @param height the height of the image in pixels
  2125. * @return size of the image data in bytes
  2126. */
  2127. int avpicture_fill(AVPicture *picture, uint8_t *ptr,
  2128. int pix_fmt, int width, int height);
  2129. int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height,
  2130. unsigned char *dest, int dest_size);
  2131. /**
  2132. * Calculate the size in bytes that a picture of the given width and height
  2133. * would occupy if stored in the given picture format.
  2134. *
  2135. * @param pix_fmt the given picture format
  2136. * @param width the width of the image
  2137. * @param height the height of the image
  2138. * @return Image data size in bytes
  2139. */
  2140. int avpicture_get_size(int pix_fmt, int width, int height);
  2141. void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
  2142. const char *avcodec_get_pix_fmt_name(int pix_fmt);
  2143. void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
  2144. enum PixelFormat avcodec_get_pix_fmt(const char* name);
  2145. unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat p);
  2146. #define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */
  2147. #define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */
  2148. #define FF_LOSS_COLORSPACE 0x0004 /**< loss due to color space conversion */
  2149. #define FF_LOSS_ALPHA 0x0008 /**< loss of alpha bits */
  2150. #define FF_LOSS_COLORQUANT 0x0010 /**< loss due to color quantization */
  2151. #define FF_LOSS_CHROMA 0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */
  2152. /**
  2153. * Computes what kind of losses will occur when converting from one specific
  2154. * pixel format to another.
  2155. * When converting from one pixel format to another, information loss may occur.
  2156. * For example, when converting from RGB24 to GRAY, the color information will
  2157. * be lost. Similarly, other losses occur when converting from some formats to
  2158. * other formats. These losses can involve loss of chroma, but also loss of
  2159. * resolution, loss of color depth, loss due to the color space conversion, loss
  2160. * of the alpha bits or loss due to color quantization.
  2161. * avcodec_get_fix_fmt_loss() informs you about the various types of losses
  2162. * which will occur when converting from one pixel format to another.
  2163. *
  2164. * @param[in] dst_pix_fmt destination pixel format
  2165. * @param[in] src_pix_fmt source pixel format
  2166. * @param[in] has_alpha Whether the source pixel format alpha channel is used.
  2167. * @return Combination of flags informing you what kind of losses will occur.
  2168. */
  2169. int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
  2170. int has_alpha);
  2171. /**
  2172. * Finds the best pixel format to convert to given a certain source pixel
  2173. * format. When converting from one pixel format to another, information loss
  2174. * may occur. For example, when converting from RGB24 to GRAY, the color
  2175. * information will be lost. Similarly, other losses occur when converting from
  2176. * some formats to other formats. avcodec_find_best_pix_fmt() searches which of
  2177. * the given pixel formats should be used to suffer the least amount of loss.
  2178. * The pixel formats from which it chooses one, are determined by the
  2179. * \p pix_fmt_mask parameter.
  2180. *
  2181. * @code
  2182. * src_pix_fmt = PIX_FMT_YUV420P;
  2183. * pix_fmt_mask = (1 << PIX_FMT_YUV422P) || (1 << PIX_FMT_RGB24);
  2184. * dst_pix_fmt = avcodec_find_best_pix_fmt(pix_fmt_mask, src_pix_fmt, alpha, &loss);
  2185. * @endcode
  2186. *
  2187. * @param[in] pix_fmt_mask bitmask determining which pixel format to choose from
  2188. * @param[in] src_pix_fmt source pixel format
  2189. * @param[in] has_alpha Whether the source pixel format alpha channel is used.
  2190. * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur.
  2191. * @return The best pixel format to convert to or -1 if none was found.
  2192. */
  2193. int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
  2194. int has_alpha, int *loss_ptr);
  2195. /**
  2196. * Print in buf the string corresponding to the pixel format with
  2197. * number pix_fmt, or an header if pix_fmt is negative.
  2198. *
  2199. * @param[in] buf the buffer where to write the string
  2200. * @param[in] buf_size the size of buf
  2201. * @param[in] pix_fmt the number of the pixel format to print the corresponding info string, or
  2202. * a negative value to print the corresponding header.
  2203. * Meaningful values for obtaining a pixel format info vary from 0 to PIX_FMT_NB -1.
  2204. */
  2205. void avcodec_pix_fmt_string (char *buf, int buf_size, int pix_fmt);
  2206. #define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */
  2207. #define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */
  2208. /**
  2209. * Tell if an image really has transparent alpha values.
  2210. * @return ored mask of FF_ALPHA_xxx constants
  2211. */
  2212. int img_get_alpha_info(const AVPicture *src,
  2213. int pix_fmt, int width, int height);
  2214. #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
  2215. /**
  2216. * convert among pixel formats
  2217. * @deprecated Use the software scaler (swscale) instead.
  2218. */
  2219. attribute_deprecated int img_convert(AVPicture *dst, int dst_pix_fmt,
  2220. const AVPicture *src, int pix_fmt,
  2221. int width, int height);
  2222. #endif
  2223. /* deinterlace a picture */
  2224. /* deinterlace - if not supported return -1 */
  2225. int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
  2226. int pix_fmt, int width, int height);
  2227. /* external high level API */
  2228. #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
  2229. extern AVCodec *first_avcodec;
  2230. #endif
  2231. AVCodec *av_codec_next(AVCodec *c);
  2232. /* returns LIBAVCODEC_VERSION_INT constant */
  2233. unsigned avcodec_version(void);
  2234. /* returns LIBAVCODEC_BUILD constant */
  2235. unsigned avcodec_build(void);
  2236. /**
  2237. * Initializes libavcodec.
  2238. *
  2239. * @warning This function \e must be called before any other libavcodec
  2240. * function.
  2241. */
  2242. void avcodec_init(void);
  2243. void register_avcodec(AVCodec *format);
  2244. /**
  2245. * Finds a registered encoder with a matching codec ID.
  2246. *
  2247. * @param id CodecID of the requested encoder
  2248. * @return An encoder if one was found, NULL otherwise.
  2249. */
  2250. AVCodec *avcodec_find_encoder(enum CodecID id);
  2251. /**
  2252. * Finds a registered encoder with the specified name.
  2253. *
  2254. * @param name name of the requested encoder
  2255. * @return An encoder if one was found, NULL otherwise.
  2256. */
  2257. AVCodec *avcodec_find_encoder_by_name(const char *name);
  2258. /**
  2259. * Finds a registered decoder with a matching codec ID.
  2260. *
  2261. * @param id CodecID of the requested decoder
  2262. * @return A decoder if one was found, NULL otherwise.
  2263. */
  2264. AVCodec *avcodec_find_decoder(enum CodecID id);
  2265. /**
  2266. * Finds a registered decoder with the specified name.
  2267. *
  2268. * @param name name of the requested decoder
  2269. * @return A decoder if one was found, NULL otherwise.
  2270. */
  2271. AVCodec *avcodec_find_decoder_by_name(const char *name);
  2272. void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
  2273. /**
  2274. * Sets the fields of the given AVCodecContext to default values.
  2275. *
  2276. * @param s The AVCodecContext of which the fields should be set to default values.
  2277. */
  2278. void avcodec_get_context_defaults(AVCodecContext *s);
  2279. /** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
  2280. * we WILL change its arguments and name a few times! */
  2281. void avcodec_get_context_defaults2(AVCodecContext *s, enum CodecType);
  2282. /**
  2283. * Allocates an AVCodecContext and sets its fields to default values. The
  2284. * resulting struct can be deallocated by simply calling av_free().
  2285. *
  2286. * @return An AVCodecContext filled with default values or NULL on failure.
  2287. * @see avcodec_get_context_defaults
  2288. */
  2289. AVCodecContext *avcodec_alloc_context(void);
  2290. /** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
  2291. * we WILL change its arguments and name a few times! */
  2292. AVCodecContext *avcodec_alloc_context2(enum CodecType);
  2293. /**
  2294. * Sets the fields of the given AVFrame to default values.
  2295. *
  2296. * @param pic The AVFrame of which the fields should be set to default values.
  2297. */
  2298. void avcodec_get_frame_defaults(AVFrame *pic);
  2299. /**
  2300. * Allocates an AVFrame and sets its fields to default values. The resulting
  2301. * struct can be deallocated by simply calling av_free().
  2302. *
  2303. * @return An AVFrame filled with default values or NULL on failure.
  2304. * @see avcodec_get_frame_defaults
  2305. */
  2306. AVFrame *avcodec_alloc_frame(void);
  2307. int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
  2308. void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
  2309. int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic);
  2310. void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
  2311. /**
  2312. * Checks if the given dimension of a picture is valid, meaning that all
  2313. * bytes of the picture can be addressed with a signed int.
  2314. *
  2315. * @param[in] w Width of the picture.
  2316. * @param[in] h Height of the picture.
  2317. * @return Zero if valid, a negative value if invalid.
  2318. */
  2319. int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h);
  2320. enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
  2321. int avcodec_thread_init(AVCodecContext *s, int thread_count);
  2322. void avcodec_thread_free(AVCodecContext *s);
  2323. int avcodec_thread_execute(AVCodecContext *s, int (*func)(AVCodecContext *c2, void *arg2),void **arg, int *ret, int count);
  2324. int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void **arg, int *ret, int count);
  2325. //FIXME func typedef
  2326. /**
  2327. * Initializes the AVCodecContext to use the given AVCodec. Prior to using this
  2328. * function the context has to be allocated.
  2329. *
  2330. * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
  2331. * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
  2332. * retrieving a codec.
  2333. *
  2334. * @warning This function is not thread safe!
  2335. *
  2336. * @code
  2337. * avcodec_register_all();
  2338. * codec = avcodec_find_decoder(CODEC_ID_H264);
  2339. * if (!codec)
  2340. * exit(1);
  2341. *
  2342. * context = avcodec_alloc_context();
  2343. *
  2344. * if (avcodec_open(context, codec) < 0)
  2345. * exit(1);
  2346. * @endcode
  2347. *
  2348. * @param avctx The context which will be set up to use the given codec.
  2349. * @param codec The codec to use within the context.
  2350. * @return zero on success, a negative value on error
  2351. * @see avcodec_alloc_context, avcodec_find_decoder, avcodec_find_encoder
  2352. */
  2353. int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
  2354. /**
  2355. * @deprecated Use avcodec_decode_audio2() instead.
  2356. */
  2357. attribute_deprecated int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
  2358. int *frame_size_ptr,
  2359. const uint8_t *buf, int buf_size);
  2360. /**
  2361. * Decodes an audio frame from \p buf into \p samples.
  2362. * The avcodec_decode_audio2() function decodes an audio frame from the input
  2363. * buffer \p buf of size \p buf_size. To decode it, it makes use of the
  2364. * audio codec which was coupled with \p avctx using avcodec_open(). The
  2365. * resulting decoded frame is stored in output buffer \p samples. If no frame
  2366. * could be decompressed, \p frame_size_ptr is zero. Otherwise, it is the
  2367. * decompressed frame size in \e bytes.
  2368. *
  2369. * @warning You \e must set \p frame_size_ptr to the allocated size of the
  2370. * output buffer before calling avcodec_decode_audio2().
  2371. *
  2372. * @warning The input buffer must be \c FF_INPUT_BUFFER_PADDING_SIZE larger than
  2373. * the actual read bytes because some optimized bitstream readers read 32 or 64
  2374. * bits at once and could read over the end.
  2375. *
  2376. * @warning The end of the input buffer \p buf should be set to 0 to ensure that
  2377. * no overreading happens for damaged MPEG streams.
  2378. *
  2379. * @note You might have to align the input buffer \p buf and output buffer \p
  2380. * samples. The alignment requirements depend on the CPU: On some CPUs it isn't
  2381. * necessary at all, on others it won't work at all if not aligned and on others
  2382. * it will work but it will have an impact on performance. In practice, the
  2383. * bitstream should have 4 byte alignment at minimum and all sample data should
  2384. * be 16 byte aligned unless the CPU doesn't need it (AltiVec and SSE do). If
  2385. * the linesize is not a multiple of 16 then there's no sense in aligning the
  2386. * start of the buffer to 16.
  2387. *
  2388. * @param avctx the codec context
  2389. * @param[out] samples the output buffer
  2390. * @param[in,out] frame_size_ptr the output buffer size in bytes
  2391. * @param[in] buf the input buffer
  2392. * @param[in] buf_size the input buffer size in bytes
  2393. * @return On error a negative value is returned, otherwise the number of bytes
  2394. * used or zero if no frame could be decompressed.
  2395. */
  2396. int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples,
  2397. int *frame_size_ptr,
  2398. const uint8_t *buf, int buf_size);
  2399. /**
  2400. * Decodes a video frame from \p buf into \p picture.
  2401. * The avcodec_decode_video() function decodes a video frame from the input
  2402. * buffer \p buf of size \p buf_size. To decode it, it makes use of the
  2403. * video codec which was coupled with \p avctx using avcodec_open(). The
  2404. * resulting decoded frame is stored in \p picture.
  2405. *
  2406. * @warning The input buffer must be \c FF_INPUT_BUFFER_PADDING_SIZE larger than
  2407. * the actual read bytes because some optimized bitstream readers read 32 or 64
  2408. * bits at once and could read over the end.
  2409. *
  2410. * @warning The end of the input buffer \p buf should be set to 0 to ensure that
  2411. * no overreading happens for damaged MPEG streams.
  2412. *
  2413. * @note You might have to align the input buffer \p buf and output buffer \p
  2414. * samples. The alignment requirements depend on the CPU: on some CPUs it isn't
  2415. * necessary at all, on others it won't work at all if not aligned and on others
  2416. * it will work but it will have an impact on performance. In practice, the
  2417. * bitstream should have 4 byte alignment at minimum and all sample data should
  2418. * be 16 byte aligned unless the CPU doesn't need it (AltiVec and SSE do). If
  2419. * the linesize is not a multiple of 16 then there's no sense in aligning the
  2420. * start of the buffer to 16.
  2421. *
  2422. * @param avctx the codec context
  2423. * @param[out] picture The AVFrame in which the decoded video frame will be stored.
  2424. * @param[in] buf the input buffer
  2425. * @param[in] buf_size the size of the input buffer in bytes
  2426. * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero.
  2427. * @return On error a negative value is returned, otherwise the number of bytes
  2428. * used or zero if no frame could be decompressed.
  2429. */
  2430. int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
  2431. int *got_picture_ptr,
  2432. const uint8_t *buf, int buf_size);
  2433. /* Decode a subtitle message. Return -1 if error, otherwise return the
  2434. * number of bytes used. If no subtitle could be decompressed,
  2435. * got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. */
  2436. int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub,
  2437. int *got_sub_ptr,
  2438. const uint8_t *buf, int buf_size);
  2439. int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata,
  2440. int *data_size_ptr,
  2441. uint8_t *buf, int buf_size);
  2442. /**
  2443. * Encodes an audio frame from \p samples into \p buf.
  2444. * The avcodec_encode_audio() function encodes an audio frame from the input
  2445. * buffer \p samples. To encode it, it makes use of the audio codec which was
  2446. * coupled with \p avctx using avcodec_open(). The resulting encoded frame is
  2447. * stored in output buffer \p buf.
  2448. *
  2449. * @note The output buffer should be at least \c FF_MIN_BUFFER_SIZE bytes large.
  2450. *
  2451. * @param avctx the codec context
  2452. * @param[out] buf the output buffer
  2453. * @param[in] buf_size the output buffer size
  2454. * @param[in] samples the input buffer containing the samples
  2455. * The number of samples read from this buffer is frame_size*channels,
  2456. * both of which are defined in \p avctx.
  2457. * @return On error a negative value is returned, on success zero or the number
  2458. * of bytes used to encode the data read from the input buffer.
  2459. */
  2460. int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
  2461. const short *samples);
  2462. /**
  2463. * Encodes a video frame from \p pict into \p buf.
  2464. * The avcodec_encode_video() function encodes a video frame from the input
  2465. * \p pict. To encode it, it makes use of the video codec which was coupled with
  2466. * \p avctx using avcodec_open(). The resulting encoded bytes representing the
  2467. * frame are stored in the output buffer \p buf. The input picture should be
  2468. * stored using a specific format, namely \c avctx.pix_fmt.
  2469. *
  2470. * @param avctx the codec context
  2471. * @param[out] buf the output buffer for the bitstream of encoded frame
  2472. * @param[in] buf_size the size of the output buffer in bytes
  2473. * @param[in] pict the input picture to encode
  2474. * @return On error a negative value is returned, on success zero or the number
  2475. * of bytes used from the input buffer.
  2476. */
  2477. int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
  2478. const AVFrame *pict);
  2479. int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
  2480. const AVSubtitle *sub);
  2481. int avcodec_close(AVCodecContext *avctx);
  2482. void avcodec_register_all(void);
  2483. /**
  2484. * Flush buffers, should be called when seeking or when switching to a different stream.
  2485. */
  2486. void avcodec_flush_buffers(AVCodecContext *avctx);
  2487. void avcodec_default_free_buffers(AVCodecContext *s);
  2488. /* misc useful functions */
  2489. /**
  2490. * Returns a single letter to describe the given picture type \p pict_type.
  2491. *
  2492. * @param[in] pict_type the picture type
  2493. * @return A single character representing the picture type.
  2494. */
  2495. char av_get_pict_type_char(int pict_type);
  2496. /**
  2497. * Returns codec bits per sample.
  2498. *
  2499. * @param[in] codec_id the codec
  2500. * @return Number of bits per sample or zero if unknown for the given codec.
  2501. */
  2502. int av_get_bits_per_sample(enum CodecID codec_id);
  2503. /**
  2504. * Returns sample format bits per sample.
  2505. *
  2506. * @param[in] sample_fmt the sample format
  2507. * @return Number of bits per sample or zero if unknown for the given sample format.
  2508. */
  2509. int av_get_bits_per_sample_format(enum SampleFormat sample_fmt);
  2510. /* frame parsing */
  2511. typedef struct AVCodecParserContext {
  2512. void *priv_data;
  2513. struct AVCodecParser *parser;
  2514. int64_t frame_offset; /* offset of the current frame */
  2515. int64_t cur_offset; /* current offset
  2516. (incremented by each av_parser_parse()) */
  2517. int64_t last_frame_offset; /* offset of the last frame */
  2518. /* video info */
  2519. int pict_type; /* XXX: Put it back in AVCodecContext. */
  2520. int repeat_pict; /* XXX: Put it back in AVCodecContext. */
  2521. int64_t pts; /* pts of the current frame */
  2522. int64_t dts; /* dts of the current frame */
  2523. /* private data */
  2524. int64_t last_pts;
  2525. int64_t last_dts;
  2526. int fetch_timestamp;
  2527. #define AV_PARSER_PTS_NB 4
  2528. int cur_frame_start_index;
  2529. int64_t cur_frame_offset[AV_PARSER_PTS_NB];
  2530. int64_t cur_frame_pts[AV_PARSER_PTS_NB];
  2531. int64_t cur_frame_dts[AV_PARSER_PTS_NB];
  2532. int flags;
  2533. #define PARSER_FLAG_COMPLETE_FRAMES 0x0001
  2534. int64_t offset; ///< byte offset from starting packet start
  2535. int64_t last_offset;
  2536. } AVCodecParserContext;
  2537. typedef struct AVCodecParser {
  2538. int codec_ids[5]; /* several codec IDs are permitted */
  2539. int priv_data_size;
  2540. int (*parser_init)(AVCodecParserContext *s);
  2541. int (*parser_parse)(AVCodecParserContext *s,
  2542. AVCodecContext *avctx,
  2543. const uint8_t **poutbuf, int *poutbuf_size,
  2544. const uint8_t *buf, int buf_size);
  2545. void (*parser_close)(AVCodecParserContext *s);
  2546. int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size);
  2547. struct AVCodecParser *next;
  2548. } AVCodecParser;
  2549. #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
  2550. extern AVCodecParser *av_first_parser;
  2551. #endif
  2552. AVCodecParser *av_parser_next(AVCodecParser *c);
  2553. void av_register_codec_parser(AVCodecParser *parser);
  2554. AVCodecParserContext *av_parser_init(int codec_id);
  2555. int av_parser_parse(AVCodecParserContext *s,
  2556. AVCodecContext *avctx,
  2557. uint8_t **poutbuf, int *poutbuf_size,
  2558. const uint8_t *buf, int buf_size,
  2559. int64_t pts, int64_t dts);
  2560. int av_parser_change(AVCodecParserContext *s,
  2561. AVCodecContext *avctx,
  2562. uint8_t **poutbuf, int *poutbuf_size,
  2563. const uint8_t *buf, int buf_size, int keyframe);
  2564. void av_parser_close(AVCodecParserContext *s);
  2565. typedef struct AVBitStreamFilterContext {
  2566. void *priv_data;
  2567. struct AVBitStreamFilter *filter;
  2568. AVCodecParserContext *parser;
  2569. struct AVBitStreamFilterContext *next;
  2570. } AVBitStreamFilterContext;
  2571. typedef struct AVBitStreamFilter {
  2572. const char *name;
  2573. int priv_data_size;
  2574. int (*filter)(AVBitStreamFilterContext *bsfc,
  2575. AVCodecContext *avctx, const char *args,
  2576. uint8_t **poutbuf, int *poutbuf_size,
  2577. const uint8_t *buf, int buf_size, int keyframe);
  2578. void (*close)(AVBitStreamFilterContext *bsfc);
  2579. struct AVBitStreamFilter *next;
  2580. } AVBitStreamFilter;
  2581. void av_register_bitstream_filter(AVBitStreamFilter *bsf);
  2582. AVBitStreamFilterContext *av_bitstream_filter_init(const char *name);
  2583. int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc,
  2584. AVCodecContext *avctx, const char *args,
  2585. uint8_t **poutbuf, int *poutbuf_size,
  2586. const uint8_t *buf, int buf_size, int keyframe);
  2587. void av_bitstream_filter_close(AVBitStreamFilterContext *bsf);
  2588. AVBitStreamFilter *av_bitstream_filter_next(AVBitStreamFilter *f);
  2589. /* memory */
  2590. /**
  2591. * Reallocates the given block if it is not large enough, otherwise it
  2592. * does nothing.
  2593. *
  2594. * @see av_realloc
  2595. */
  2596. void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
  2597. /* for static data only */
  2598. /**
  2599. * Frees all static arrays and resets their pointers to 0.
  2600. * Call this function to release all statically allocated tables.
  2601. *
  2602. * @deprecated. Code which uses av_free_static is broken/misdesigned
  2603. * and should correctly use static arrays
  2604. *
  2605. */
  2606. attribute_deprecated void av_free_static(void);
  2607. /**
  2608. * Allocation of static arrays.
  2609. *
  2610. * @warning Do not use for normal allocation.
  2611. *
  2612. * @param[in] size The amount of memory you need in bytes.
  2613. * @return block of memory of the requested size
  2614. * @deprecated. Code which uses av_mallocz_static is broken/misdesigned
  2615. * and should correctly use static arrays
  2616. */
  2617. attribute_deprecated void *av_mallocz_static(unsigned int size);
  2618. /**
  2619. * Copy image 'src' to 'dst'.
  2620. */
  2621. void av_picture_copy(AVPicture *dst, const AVPicture *src,
  2622. int pix_fmt, int width, int height);
  2623. /**
  2624. * Crop image top and left side.
  2625. */
  2626. int av_picture_crop(AVPicture *dst, const AVPicture *src,
  2627. int pix_fmt, int top_band, int left_band);
  2628. /**
  2629. * Pad image.
  2630. */
  2631. int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, int pix_fmt,
  2632. int padtop, int padbottom, int padleft, int padright, int *color);
  2633. #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
  2634. /**
  2635. * @deprecated Use the software scaler (swscale) instead.
  2636. */
  2637. attribute_deprecated void img_copy(AVPicture *dst, const AVPicture *src,
  2638. int pix_fmt, int width, int height);
  2639. /**
  2640. * @deprecated Use the software scaler (swscale) instead.
  2641. */
  2642. attribute_deprecated int img_crop(AVPicture *dst, const AVPicture *src,
  2643. int pix_fmt, int top_band, int left_band);
  2644. /**
  2645. * @deprecated Use the software scaler (swscale) instead.
  2646. */
  2647. attribute_deprecated int img_pad(AVPicture *dst, const AVPicture *src, int height, int width, int pix_fmt,
  2648. int padtop, int padbottom, int padleft, int padright, int *color);
  2649. #endif
  2650. extern unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
  2651. /**
  2652. * Parses \p str and put in \p width_ptr and \p height_ptr the detected values.
  2653. *
  2654. * @return 0 in case of a successful parsing, a negative value otherwise
  2655. * @param[in] str the string to parse: it has to be a string in the format
  2656. * <width>x<height> or a valid video frame size abbreviation.
  2657. * @param[in,out] width_ptr pointer to the variable which will contain the detected
  2658. * frame width value
  2659. * @param[in,out] height_ptr pointer to the variable which will contain the detected
  2660. * frame height value
  2661. */
  2662. int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str);
  2663. /**
  2664. * Parses \p str and put in \p frame_rate the detected values.
  2665. *
  2666. * @return 0 in case of a successful parsing, a negative value otherwise
  2667. * @param[in] str the string to parse: it has to be a string in the format
  2668. * <frame_rate_nom>/<frame_rate_den>, a float number or a valid video rate abbreviation
  2669. * @param[in,out] frame_rate pointer to the AVRational which will contain the detected
  2670. * frame rate
  2671. */
  2672. int av_parse_video_frame_rate(AVRational *frame_rate, const char *str);
  2673. /* error handling */
  2674. #if EINVAL > 0
  2675. #define AVERROR(e) (-(e)) /**< Returns a negative error code from a POSIX error code, to return from library functions. */
  2676. #define AVUNERROR(e) (-(e)) /**< Returns a POSIX error code from a library function error return value. */
  2677. #else
  2678. /* Some platforms have E* and errno already negated. */
  2679. #define AVERROR(e) (e)
  2680. #define AVUNERROR(e) (e)
  2681. #endif
  2682. #define AVERROR_UNKNOWN AVERROR(EINVAL) /**< unknown error */
  2683. #define AVERROR_IO AVERROR(EIO) /**< I/O error */
  2684. #define AVERROR_NUMEXPECTED AVERROR(EDOM) /**< Number syntax expected in filename. */
  2685. #define AVERROR_INVALIDDATA AVERROR(EINVAL) /**< invalid data found */
  2686. #define AVERROR_NOMEM AVERROR(ENOMEM) /**< not enough memory */
  2687. #define AVERROR_NOFMT AVERROR(EILSEQ) /**< unknown format */
  2688. #define AVERROR_NOTSUPP AVERROR(ENOSYS) /**< Operation not supported. */
  2689. #define AVERROR_NOENT AVERROR(ENOENT) /**< No such file or directory. */
  2690. #define AVERROR_PATCHWELCOME -MKTAG('P','A','W','E') /**< Not yet implemented in FFmpeg. Patches welcome. */
  2691. #endif /* FFMPEG_AVCODEC_H */