avcodec.h 162 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929
  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 AVCODEC_AVCODEC_H
  21. #define AVCODEC_AVCODEC_H
  22. /**
  23. * @file
  24. * external API header
  25. */
  26. #include <errno.h>
  27. #include "libavutil/samplefmt.h"
  28. #include "libavutil/avutil.h"
  29. #include "libavutil/cpu.h"
  30. #include "libavutil/dict.h"
  31. #include "libavutil/log.h"
  32. #include "libavutil/pixfmt.h"
  33. #include "libavutil/rational.h"
  34. #include "libavutil/audioconvert.h"
  35. #include "libavcodec/version.h"
  36. /**
  37. * @defgroup libavc Encoding/Decoding Library
  38. * @{
  39. *
  40. * @defgroup lavc_decoding Decoding
  41. * @{
  42. * @}
  43. *
  44. * @defgroup lavc_encoding Encoding
  45. * @{
  46. * @}
  47. *
  48. * @defgroup lavc_codec Codecs
  49. * @{
  50. * @defgroup lavc_codec_native Native Codecs
  51. * @{
  52. * @}
  53. * @defgroup lavc_codec_wrappers External library wrappers
  54. * @{
  55. * @}
  56. * @defgroup lavc_codec_hwaccel Hardware Accelerators bridge
  57. * @{
  58. * @}
  59. * @}
  60. * @defgroup lavc_internal Internal
  61. * @{
  62. * @}
  63. * @}
  64. *
  65. */
  66. /**
  67. * @defgroup lavc_core Core functions/structures.
  68. * @ingroup libavc
  69. *
  70. * Basic definitions, functions for querying libavcodec capabilities,
  71. * allocating core structures, etc.
  72. * @{
  73. */
  74. /**
  75. * Identify the syntax and semantics of the bitstream.
  76. * The principle is roughly:
  77. * Two decoders with the same ID can decode the same streams.
  78. * Two encoders with the same ID can encode compatible streams.
  79. * There may be slight deviations from the principle due to implementation
  80. * details.
  81. *
  82. * If you add a codec ID to this list, add it so that
  83. * 1. no value of a existing codec ID changes (that would break ABI),
  84. * 2. Give it a value which when taken as ASCII is recognized uniquely by a human as this specific codec.
  85. * This ensures that 2 forks can independently add AVCodecIDs without producing conflicts.
  86. *
  87. * After adding new codec IDs, do not forget to add an entry to the codec
  88. * descriptor list and bump libavcodec minor version.
  89. */
  90. enum AVCodecID {
  91. AV_CODEC_ID_NONE,
  92. /* video codecs */
  93. AV_CODEC_ID_MPEG1VIDEO,
  94. AV_CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding
  95. AV_CODEC_ID_MPEG2VIDEO_XVMC,
  96. AV_CODEC_ID_H261,
  97. AV_CODEC_ID_H263,
  98. AV_CODEC_ID_RV10,
  99. AV_CODEC_ID_RV20,
  100. AV_CODEC_ID_MJPEG,
  101. AV_CODEC_ID_MJPEGB,
  102. AV_CODEC_ID_LJPEG,
  103. AV_CODEC_ID_SP5X,
  104. AV_CODEC_ID_JPEGLS,
  105. AV_CODEC_ID_MPEG4,
  106. AV_CODEC_ID_RAWVIDEO,
  107. AV_CODEC_ID_MSMPEG4V1,
  108. AV_CODEC_ID_MSMPEG4V2,
  109. AV_CODEC_ID_MSMPEG4V3,
  110. AV_CODEC_ID_WMV1,
  111. AV_CODEC_ID_WMV2,
  112. AV_CODEC_ID_H263P,
  113. AV_CODEC_ID_H263I,
  114. AV_CODEC_ID_FLV1,
  115. AV_CODEC_ID_SVQ1,
  116. AV_CODEC_ID_SVQ3,
  117. AV_CODEC_ID_DVVIDEO,
  118. AV_CODEC_ID_HUFFYUV,
  119. AV_CODEC_ID_CYUV,
  120. AV_CODEC_ID_H264,
  121. AV_CODEC_ID_INDEO3,
  122. AV_CODEC_ID_VP3,
  123. AV_CODEC_ID_THEORA,
  124. AV_CODEC_ID_ASV1,
  125. AV_CODEC_ID_ASV2,
  126. AV_CODEC_ID_FFV1,
  127. AV_CODEC_ID_4XM,
  128. AV_CODEC_ID_VCR1,
  129. AV_CODEC_ID_CLJR,
  130. AV_CODEC_ID_MDEC,
  131. AV_CODEC_ID_ROQ,
  132. AV_CODEC_ID_INTERPLAY_VIDEO,
  133. AV_CODEC_ID_XAN_WC3,
  134. AV_CODEC_ID_XAN_WC4,
  135. AV_CODEC_ID_RPZA,
  136. AV_CODEC_ID_CINEPAK,
  137. AV_CODEC_ID_WS_VQA,
  138. AV_CODEC_ID_MSRLE,
  139. AV_CODEC_ID_MSVIDEO1,
  140. AV_CODEC_ID_IDCIN,
  141. AV_CODEC_ID_8BPS,
  142. AV_CODEC_ID_SMC,
  143. AV_CODEC_ID_FLIC,
  144. AV_CODEC_ID_TRUEMOTION1,
  145. AV_CODEC_ID_VMDVIDEO,
  146. AV_CODEC_ID_MSZH,
  147. AV_CODEC_ID_ZLIB,
  148. AV_CODEC_ID_QTRLE,
  149. AV_CODEC_ID_SNOW,
  150. AV_CODEC_ID_TSCC,
  151. AV_CODEC_ID_ULTI,
  152. AV_CODEC_ID_QDRAW,
  153. AV_CODEC_ID_VIXL,
  154. AV_CODEC_ID_QPEG,
  155. AV_CODEC_ID_PNG,
  156. AV_CODEC_ID_PPM,
  157. AV_CODEC_ID_PBM,
  158. AV_CODEC_ID_PGM,
  159. AV_CODEC_ID_PGMYUV,
  160. AV_CODEC_ID_PAM,
  161. AV_CODEC_ID_FFVHUFF,
  162. AV_CODEC_ID_RV30,
  163. AV_CODEC_ID_RV40,
  164. AV_CODEC_ID_VC1,
  165. AV_CODEC_ID_WMV3,
  166. AV_CODEC_ID_LOCO,
  167. AV_CODEC_ID_WNV1,
  168. AV_CODEC_ID_AASC,
  169. AV_CODEC_ID_INDEO2,
  170. AV_CODEC_ID_FRAPS,
  171. AV_CODEC_ID_TRUEMOTION2,
  172. AV_CODEC_ID_BMP,
  173. AV_CODEC_ID_CSCD,
  174. AV_CODEC_ID_MMVIDEO,
  175. AV_CODEC_ID_ZMBV,
  176. AV_CODEC_ID_AVS,
  177. AV_CODEC_ID_SMACKVIDEO,
  178. AV_CODEC_ID_NUV,
  179. AV_CODEC_ID_KMVC,
  180. AV_CODEC_ID_FLASHSV,
  181. AV_CODEC_ID_CAVS,
  182. AV_CODEC_ID_JPEG2000,
  183. AV_CODEC_ID_VMNC,
  184. AV_CODEC_ID_VP5,
  185. AV_CODEC_ID_VP6,
  186. AV_CODEC_ID_VP6F,
  187. AV_CODEC_ID_TARGA,
  188. AV_CODEC_ID_DSICINVIDEO,
  189. AV_CODEC_ID_TIERTEXSEQVIDEO,
  190. AV_CODEC_ID_TIFF,
  191. AV_CODEC_ID_GIF,
  192. AV_CODEC_ID_DXA,
  193. AV_CODEC_ID_DNXHD,
  194. AV_CODEC_ID_THP,
  195. AV_CODEC_ID_SGI,
  196. AV_CODEC_ID_C93,
  197. AV_CODEC_ID_BETHSOFTVID,
  198. AV_CODEC_ID_PTX,
  199. AV_CODEC_ID_TXD,
  200. AV_CODEC_ID_VP6A,
  201. AV_CODEC_ID_AMV,
  202. AV_CODEC_ID_VB,
  203. AV_CODEC_ID_PCX,
  204. AV_CODEC_ID_SUNRAST,
  205. AV_CODEC_ID_INDEO4,
  206. AV_CODEC_ID_INDEO5,
  207. AV_CODEC_ID_MIMIC,
  208. AV_CODEC_ID_RL2,
  209. AV_CODEC_ID_ESCAPE124,
  210. AV_CODEC_ID_DIRAC,
  211. AV_CODEC_ID_BFI,
  212. AV_CODEC_ID_CMV,
  213. AV_CODEC_ID_MOTIONPIXELS,
  214. AV_CODEC_ID_TGV,
  215. AV_CODEC_ID_TGQ,
  216. AV_CODEC_ID_TQI,
  217. AV_CODEC_ID_AURA,
  218. AV_CODEC_ID_AURA2,
  219. AV_CODEC_ID_V210X,
  220. AV_CODEC_ID_TMV,
  221. AV_CODEC_ID_V210,
  222. AV_CODEC_ID_DPX,
  223. AV_CODEC_ID_MAD,
  224. AV_CODEC_ID_FRWU,
  225. AV_CODEC_ID_FLASHSV2,
  226. AV_CODEC_ID_CDGRAPHICS,
  227. AV_CODEC_ID_R210,
  228. AV_CODEC_ID_ANM,
  229. AV_CODEC_ID_BINKVIDEO,
  230. AV_CODEC_ID_IFF_ILBM,
  231. AV_CODEC_ID_IFF_BYTERUN1,
  232. AV_CODEC_ID_KGV1,
  233. AV_CODEC_ID_YOP,
  234. AV_CODEC_ID_VP8,
  235. AV_CODEC_ID_PICTOR,
  236. AV_CODEC_ID_ANSI,
  237. AV_CODEC_ID_A64_MULTI,
  238. AV_CODEC_ID_A64_MULTI5,
  239. AV_CODEC_ID_R10K,
  240. AV_CODEC_ID_MXPEG,
  241. AV_CODEC_ID_LAGARITH,
  242. AV_CODEC_ID_PRORES,
  243. AV_CODEC_ID_JV,
  244. AV_CODEC_ID_DFA,
  245. AV_CODEC_ID_WMV3IMAGE,
  246. AV_CODEC_ID_VC1IMAGE,
  247. AV_CODEC_ID_UTVIDEO,
  248. AV_CODEC_ID_BMV_VIDEO,
  249. AV_CODEC_ID_VBLE,
  250. AV_CODEC_ID_DXTORY,
  251. AV_CODEC_ID_V410,
  252. AV_CODEC_ID_XWD,
  253. AV_CODEC_ID_CDXL,
  254. AV_CODEC_ID_XBM,
  255. AV_CODEC_ID_ZEROCODEC,
  256. AV_CODEC_ID_MSS1,
  257. AV_CODEC_ID_MSA1,
  258. AV_CODEC_ID_TSCC2,
  259. AV_CODEC_ID_MTS2,
  260. AV_CODEC_ID_CLLC,
  261. AV_CODEC_ID_MSS2,
  262. AV_CODEC_ID_Y41P = MKBETAG('Y','4','1','P'),
  263. AV_CODEC_ID_ESCAPE130 = MKBETAG('E','1','3','0'),
  264. AV_CODEC_ID_EXR = MKBETAG('0','E','X','R'),
  265. AV_CODEC_ID_AVRP = MKBETAG('A','V','R','P'),
  266. AV_CODEC_ID_G2M = MKBETAG( 0 ,'G','2','M'),
  267. AV_CODEC_ID_AVUI = MKBETAG('A','V','U','I'),
  268. AV_CODEC_ID_AYUV = MKBETAG('A','Y','U','V'),
  269. AV_CODEC_ID_TARGA_Y216 = MKBETAG('T','2','1','6'),
  270. AV_CODEC_ID_V308 = MKBETAG('V','3','0','8'),
  271. AV_CODEC_ID_V408 = MKBETAG('V','4','0','8'),
  272. AV_CODEC_ID_YUV4 = MKBETAG('Y','U','V','4'),
  273. AV_CODEC_ID_SANM = MKBETAG('S','A','N','M'),
  274. AV_CODEC_ID_PAF_VIDEO = MKBETAG('P','A','F','V'),
  275. AV_CODEC_ID_AVRN = MKBETAG('A','V','R','n'),
  276. AV_CODEC_ID_CPIA = MKBETAG('C','P','I','A'),
  277. /* various PCM "codecs" */
  278. AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
  279. AV_CODEC_ID_PCM_S16LE = 0x10000,
  280. AV_CODEC_ID_PCM_S16BE,
  281. AV_CODEC_ID_PCM_U16LE,
  282. AV_CODEC_ID_PCM_U16BE,
  283. AV_CODEC_ID_PCM_S8,
  284. AV_CODEC_ID_PCM_U8,
  285. AV_CODEC_ID_PCM_MULAW,
  286. AV_CODEC_ID_PCM_ALAW,
  287. AV_CODEC_ID_PCM_S32LE,
  288. AV_CODEC_ID_PCM_S32BE,
  289. AV_CODEC_ID_PCM_U32LE,
  290. AV_CODEC_ID_PCM_U32BE,
  291. AV_CODEC_ID_PCM_S24LE,
  292. AV_CODEC_ID_PCM_S24BE,
  293. AV_CODEC_ID_PCM_U24LE,
  294. AV_CODEC_ID_PCM_U24BE,
  295. AV_CODEC_ID_PCM_S24DAUD,
  296. AV_CODEC_ID_PCM_ZORK,
  297. AV_CODEC_ID_PCM_S16LE_PLANAR,
  298. AV_CODEC_ID_PCM_DVD,
  299. AV_CODEC_ID_PCM_F32BE,
  300. AV_CODEC_ID_PCM_F32LE,
  301. AV_CODEC_ID_PCM_F64BE,
  302. AV_CODEC_ID_PCM_F64LE,
  303. AV_CODEC_ID_PCM_BLURAY,
  304. AV_CODEC_ID_PCM_LXF,
  305. AV_CODEC_ID_S302M,
  306. AV_CODEC_ID_PCM_S8_PLANAR,
  307. /* various ADPCM codecs */
  308. AV_CODEC_ID_ADPCM_IMA_QT = 0x11000,
  309. AV_CODEC_ID_ADPCM_IMA_WAV,
  310. AV_CODEC_ID_ADPCM_IMA_DK3,
  311. AV_CODEC_ID_ADPCM_IMA_DK4,
  312. AV_CODEC_ID_ADPCM_IMA_WS,
  313. AV_CODEC_ID_ADPCM_IMA_SMJPEG,
  314. AV_CODEC_ID_ADPCM_MS,
  315. AV_CODEC_ID_ADPCM_4XM,
  316. AV_CODEC_ID_ADPCM_XA,
  317. AV_CODEC_ID_ADPCM_ADX,
  318. AV_CODEC_ID_ADPCM_EA,
  319. AV_CODEC_ID_ADPCM_G726,
  320. AV_CODEC_ID_ADPCM_CT,
  321. AV_CODEC_ID_ADPCM_SWF,
  322. AV_CODEC_ID_ADPCM_YAMAHA,
  323. AV_CODEC_ID_ADPCM_SBPRO_4,
  324. AV_CODEC_ID_ADPCM_SBPRO_3,
  325. AV_CODEC_ID_ADPCM_SBPRO_2,
  326. AV_CODEC_ID_ADPCM_THP,
  327. AV_CODEC_ID_ADPCM_IMA_AMV,
  328. AV_CODEC_ID_ADPCM_EA_R1,
  329. AV_CODEC_ID_ADPCM_EA_R3,
  330. AV_CODEC_ID_ADPCM_EA_R2,
  331. AV_CODEC_ID_ADPCM_IMA_EA_SEAD,
  332. AV_CODEC_ID_ADPCM_IMA_EA_EACS,
  333. AV_CODEC_ID_ADPCM_EA_XAS,
  334. AV_CODEC_ID_ADPCM_EA_MAXIS_XA,
  335. AV_CODEC_ID_ADPCM_IMA_ISS,
  336. AV_CODEC_ID_ADPCM_G722,
  337. AV_CODEC_ID_ADPCM_IMA_APC,
  338. AV_CODEC_ID_VIMA = MKBETAG('V','I','M','A'),
  339. /* AMR */
  340. AV_CODEC_ID_AMR_NB = 0x12000,
  341. AV_CODEC_ID_AMR_WB,
  342. /* RealAudio codecs*/
  343. AV_CODEC_ID_RA_144 = 0x13000,
  344. AV_CODEC_ID_RA_288,
  345. /* various DPCM codecs */
  346. AV_CODEC_ID_ROQ_DPCM = 0x14000,
  347. AV_CODEC_ID_INTERPLAY_DPCM,
  348. AV_CODEC_ID_XAN_DPCM,
  349. AV_CODEC_ID_SOL_DPCM,
  350. /* audio codecs */
  351. AV_CODEC_ID_MP2 = 0x15000,
  352. AV_CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3
  353. AV_CODEC_ID_AAC,
  354. AV_CODEC_ID_AC3,
  355. AV_CODEC_ID_DTS,
  356. AV_CODEC_ID_VORBIS,
  357. AV_CODEC_ID_DVAUDIO,
  358. AV_CODEC_ID_WMAV1,
  359. AV_CODEC_ID_WMAV2,
  360. AV_CODEC_ID_MACE3,
  361. AV_CODEC_ID_MACE6,
  362. AV_CODEC_ID_VMDAUDIO,
  363. AV_CODEC_ID_FLAC,
  364. AV_CODEC_ID_MP3ADU,
  365. AV_CODEC_ID_MP3ON4,
  366. AV_CODEC_ID_SHORTEN,
  367. AV_CODEC_ID_ALAC,
  368. AV_CODEC_ID_WESTWOOD_SND1,
  369. AV_CODEC_ID_GSM, ///< as in Berlin toast format
  370. AV_CODEC_ID_QDM2,
  371. AV_CODEC_ID_COOK,
  372. AV_CODEC_ID_TRUESPEECH,
  373. AV_CODEC_ID_TTA,
  374. AV_CODEC_ID_SMACKAUDIO,
  375. AV_CODEC_ID_QCELP,
  376. AV_CODEC_ID_WAVPACK,
  377. AV_CODEC_ID_DSICINAUDIO,
  378. AV_CODEC_ID_IMC,
  379. AV_CODEC_ID_MUSEPACK7,
  380. AV_CODEC_ID_MLP,
  381. AV_CODEC_ID_GSM_MS, /* as found in WAV */
  382. AV_CODEC_ID_ATRAC3,
  383. AV_CODEC_ID_VOXWARE,
  384. AV_CODEC_ID_APE,
  385. AV_CODEC_ID_NELLYMOSER,
  386. AV_CODEC_ID_MUSEPACK8,
  387. AV_CODEC_ID_SPEEX,
  388. AV_CODEC_ID_WMAVOICE,
  389. AV_CODEC_ID_WMAPRO,
  390. AV_CODEC_ID_WMALOSSLESS,
  391. AV_CODEC_ID_ATRAC3P,
  392. AV_CODEC_ID_EAC3,
  393. AV_CODEC_ID_SIPR,
  394. AV_CODEC_ID_MP1,
  395. AV_CODEC_ID_TWINVQ,
  396. AV_CODEC_ID_TRUEHD,
  397. AV_CODEC_ID_MP4ALS,
  398. AV_CODEC_ID_ATRAC1,
  399. AV_CODEC_ID_BINKAUDIO_RDFT,
  400. AV_CODEC_ID_BINKAUDIO_DCT,
  401. AV_CODEC_ID_AAC_LATM,
  402. AV_CODEC_ID_QDMC,
  403. AV_CODEC_ID_CELT,
  404. AV_CODEC_ID_G723_1,
  405. AV_CODEC_ID_G729,
  406. AV_CODEC_ID_8SVX_EXP,
  407. AV_CODEC_ID_8SVX_FIB,
  408. AV_CODEC_ID_BMV_AUDIO,
  409. AV_CODEC_ID_RALF,
  410. AV_CODEC_ID_IAC,
  411. AV_CODEC_ID_ILBC,
  412. AV_CODEC_ID_OPUS_DEPRECATED,
  413. AV_CODEC_ID_FFWAVESYNTH = MKBETAG('F','F','W','S'),
  414. AV_CODEC_ID_8SVX_RAW = MKBETAG('8','S','V','X'),
  415. AV_CODEC_ID_SONIC = MKBETAG('S','O','N','C'),
  416. AV_CODEC_ID_SONIC_LS = MKBETAG('S','O','N','L'),
  417. AV_CODEC_ID_PAF_AUDIO = MKBETAG('P','A','F','A'),
  418. AV_CODEC_ID_OPUS = MKBETAG('O','P','U','S'),
  419. /* subtitle codecs */
  420. AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs.
  421. AV_CODEC_ID_DVD_SUBTITLE = 0x17000,
  422. AV_CODEC_ID_DVB_SUBTITLE,
  423. AV_CODEC_ID_TEXT, ///< raw UTF-8 text
  424. AV_CODEC_ID_XSUB,
  425. AV_CODEC_ID_SSA,
  426. AV_CODEC_ID_MOV_TEXT,
  427. AV_CODEC_ID_HDMV_PGS_SUBTITLE,
  428. AV_CODEC_ID_DVB_TELETEXT,
  429. AV_CODEC_ID_SRT,
  430. AV_CODEC_ID_MICRODVD = MKBETAG('m','D','V','D'),
  431. AV_CODEC_ID_EIA_608 = MKBETAG('c','6','0','8'),
  432. AV_CODEC_ID_JACOSUB = MKBETAG('J','S','U','B'),
  433. AV_CODEC_ID_SAMI = MKBETAG('S','A','M','I'),
  434. AV_CODEC_ID_REALTEXT = MKBETAG('R','T','X','T'),
  435. AV_CODEC_ID_SUBVIEWER = MKBETAG('S','u','b','V'),
  436. AV_CODEC_ID_SUBRIP = MKBETAG('S','R','i','p'),
  437. AV_CODEC_ID_WEBVTT = MKBETAG('W','V','T','T'),
  438. /* other specific kind of codecs (generally used for attachments) */
  439. AV_CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs.
  440. AV_CODEC_ID_TTF = 0x18000,
  441. AV_CODEC_ID_BINTEXT = MKBETAG('B','T','X','T'),
  442. AV_CODEC_ID_XBIN = MKBETAG('X','B','I','N'),
  443. AV_CODEC_ID_IDF = MKBETAG( 0 ,'I','D','F'),
  444. AV_CODEC_ID_OTF = MKBETAG( 0 ,'O','T','F'),
  445. AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it
  446. AV_CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS
  447. * stream (only used by libavformat) */
  448. AV_CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems
  449. * stream (only used by libavformat) */
  450. AV_CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information.
  451. #if FF_API_CODEC_ID
  452. #include "old_codec_ids.h"
  453. #endif
  454. };
  455. #if FF_API_CODEC_ID
  456. #define CodecID AVCodecID
  457. #endif
  458. /**
  459. * This struct describes the properties of a single codec described by an
  460. * AVCodecID.
  461. * @see avcodec_get_descriptor()
  462. */
  463. typedef struct AVCodecDescriptor {
  464. enum AVCodecID id;
  465. enum AVMediaType type;
  466. /**
  467. * Name of the codec described by this descriptor. It is non-empty and
  468. * unique for each codec descriptor. It should contain alphanumeric
  469. * characters and '_' only.
  470. */
  471. const char *name;
  472. /**
  473. * A more descriptive name for this codec. May be NULL.
  474. */
  475. const char *long_name;
  476. /**
  477. * Codec properties, a combination of AV_CODEC_PROP_* flags.
  478. */
  479. int props;
  480. } AVCodecDescriptor;
  481. /**
  482. * Codec uses only intra compression.
  483. * Video codecs only.
  484. */
  485. #define AV_CODEC_PROP_INTRA_ONLY (1 << 0)
  486. /**
  487. * Codec supports lossy compression. Audio and video codecs only.
  488. * @note a codec may support both lossy and lossless
  489. * compression modes
  490. */
  491. #define AV_CODEC_PROP_LOSSY (1 << 1)
  492. /**
  493. * Codec supports lossless compression. Audio and video codecs only.
  494. */
  495. #define AV_CODEC_PROP_LOSSLESS (1 << 2)
  496. #if FF_API_OLD_DECODE_AUDIO
  497. /* in bytes */
  498. #define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
  499. #endif
  500. /**
  501. * @ingroup lavc_decoding
  502. * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
  503. * This is mainly needed because some optimized bitstream readers read
  504. * 32 or 64 bit at once and could read over the end.<br>
  505. * Note: If the first 23 bits of the additional bytes are not 0, then damaged
  506. * MPEG bitstreams could cause overread and segfault.
  507. */
  508. #define FF_INPUT_BUFFER_PADDING_SIZE 16
  509. /**
  510. * @ingroup lavc_encoding
  511. * minimum encoding buffer size
  512. * Used to avoid some checks during header writing.
  513. */
  514. #define FF_MIN_BUFFER_SIZE 16384
  515. /**
  516. * @ingroup lavc_encoding
  517. * motion estimation type.
  518. */
  519. enum Motion_Est_ID {
  520. ME_ZERO = 1, ///< no search, that is use 0,0 vector whenever one is needed
  521. ME_FULL,
  522. ME_LOG,
  523. ME_PHODS,
  524. ME_EPZS, ///< enhanced predictive zonal search
  525. ME_X1, ///< reserved for experiments
  526. ME_HEX, ///< hexagon based search
  527. ME_UMH, ///< uneven multi-hexagon search
  528. ME_ITER, ///< iterative search
  529. ME_TESA, ///< transformed exhaustive search algorithm
  530. };
  531. /**
  532. * @ingroup lavc_decoding
  533. */
  534. enum AVDiscard{
  535. /* We leave some space between them for extensions (drop some
  536. * keyframes for intra-only or drop just some bidir frames). */
  537. AVDISCARD_NONE =-16, ///< discard nothing
  538. AVDISCARD_DEFAULT = 0, ///< discard useless packets like 0 size packets in avi
  539. AVDISCARD_NONREF = 8, ///< discard all non reference
  540. AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames
  541. AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes
  542. AVDISCARD_ALL = 48, ///< discard all
  543. };
  544. enum AVColorPrimaries{
  545. AVCOL_PRI_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
  546. AVCOL_PRI_UNSPECIFIED = 2,
  547. AVCOL_PRI_BT470M = 4,
  548. AVCOL_PRI_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
  549. AVCOL_PRI_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
  550. AVCOL_PRI_SMPTE240M = 7, ///< functionally identical to above
  551. AVCOL_PRI_FILM = 8,
  552. AVCOL_PRI_NB , ///< Not part of ABI
  553. };
  554. enum AVColorTransferCharacteristic{
  555. AVCOL_TRC_BT709 = 1, ///< also ITU-R BT1361
  556. AVCOL_TRC_UNSPECIFIED = 2,
  557. AVCOL_TRC_GAMMA22 = 4, ///< also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
  558. AVCOL_TRC_GAMMA28 = 5, ///< also ITU-R BT470BG
  559. AVCOL_TRC_SMPTE240M = 7,
  560. AVCOL_TRC_NB , ///< Not part of ABI
  561. };
  562. enum AVColorSpace{
  563. AVCOL_SPC_RGB = 0,
  564. AVCOL_SPC_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
  565. AVCOL_SPC_UNSPECIFIED = 2,
  566. AVCOL_SPC_FCC = 4,
  567. AVCOL_SPC_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
  568. AVCOL_SPC_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
  569. AVCOL_SPC_SMPTE240M = 7,
  570. AVCOL_SPC_YCOCG = 8, ///< Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16
  571. AVCOL_SPC_NB , ///< Not part of ABI
  572. };
  573. #define AVCOL_SPC_YCGCO AVCOL_SPC_YCOCG
  574. enum AVColorRange{
  575. AVCOL_RANGE_UNSPECIFIED = 0,
  576. AVCOL_RANGE_MPEG = 1, ///< the normal 219*2^(n-8) "MPEG" YUV ranges
  577. AVCOL_RANGE_JPEG = 2, ///< the normal 2^n-1 "JPEG" YUV ranges
  578. AVCOL_RANGE_NB , ///< Not part of ABI
  579. };
  580. /**
  581. * X X 3 4 X X are luma samples,
  582. * 1 2 1-6 are possible chroma positions
  583. * X X 5 6 X 0 is undefined/unknown position
  584. */
  585. enum AVChromaLocation{
  586. AVCHROMA_LOC_UNSPECIFIED = 0,
  587. AVCHROMA_LOC_LEFT = 1, ///< mpeg2/4, h264 default
  588. AVCHROMA_LOC_CENTER = 2, ///< mpeg1, jpeg, h263
  589. AVCHROMA_LOC_TOPLEFT = 3, ///< DV
  590. AVCHROMA_LOC_TOP = 4,
  591. AVCHROMA_LOC_BOTTOMLEFT = 5,
  592. AVCHROMA_LOC_BOTTOM = 6,
  593. AVCHROMA_LOC_NB , ///< Not part of ABI
  594. };
  595. enum AVAudioServiceType {
  596. AV_AUDIO_SERVICE_TYPE_MAIN = 0,
  597. AV_AUDIO_SERVICE_TYPE_EFFECTS = 1,
  598. AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED = 2,
  599. AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED = 3,
  600. AV_AUDIO_SERVICE_TYPE_DIALOGUE = 4,
  601. AV_AUDIO_SERVICE_TYPE_COMMENTARY = 5,
  602. AV_AUDIO_SERVICE_TYPE_EMERGENCY = 6,
  603. AV_AUDIO_SERVICE_TYPE_VOICE_OVER = 7,
  604. AV_AUDIO_SERVICE_TYPE_KARAOKE = 8,
  605. AV_AUDIO_SERVICE_TYPE_NB , ///< Not part of ABI
  606. };
  607. /**
  608. * @ingroup lavc_encoding
  609. */
  610. typedef struct RcOverride{
  611. int start_frame;
  612. int end_frame;
  613. int qscale; // If this is 0 then quality_factor will be used instead.
  614. float quality_factor;
  615. } RcOverride;
  616. #define FF_MAX_B_FRAMES 16
  617. /* encoding support
  618. These flags can be passed in AVCodecContext.flags before initialization.
  619. Note: Not everything is supported yet.
  620. */
  621. #define CODEC_FLAG_QSCALE 0x0002 ///< Use fixed qscale.
  622. #define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / advanced prediction for H.263.
  623. #define CODEC_FLAG_QPEL 0x0010 ///< Use qpel MC.
  624. #define CODEC_FLAG_GMC 0x0020 ///< Use GMC.
  625. #define CODEC_FLAG_MV0 0x0040 ///< Always try a MB with MV=<0,0>.
  626. /**
  627. * The parent program guarantees that the input for B-frames containing
  628. * streams is not written to for at least s->max_b_frames+1 frames, if
  629. * this is not set the input will be copied.
  630. */
  631. #define CODEC_FLAG_INPUT_PRESERVED 0x0100
  632. #define CODEC_FLAG_PASS1 0x0200 ///< Use internal 2pass ratecontrol in first pass mode.
  633. #define CODEC_FLAG_PASS2 0x0400 ///< Use internal 2pass ratecontrol in second pass mode.
  634. #define CODEC_FLAG_GRAY 0x2000 ///< Only decode/encode grayscale.
  635. #define CODEC_FLAG_EMU_EDGE 0x4000 ///< Don't draw edges.
  636. #define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding.
  637. #define CODEC_FLAG_TRUNCATED 0x00010000 /** Input bitstream might be truncated at a random
  638. location instead of only at frame boundaries. */
  639. #define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< Normalize adaptive quantization.
  640. #define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< Use interlaced DCT.
  641. #define CODEC_FLAG_LOW_DELAY 0x00080000 ///< Force low delay.
  642. #define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< Place global headers in extradata instead of every keyframe.
  643. #define CODEC_FLAG_BITEXACT 0x00800000 ///< Use only bitexact stuff (except (I)DCT).
  644. /* Fx : Flag for h263+ extra options */
  645. #define CODEC_FLAG_AC_PRED 0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction
  646. #define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter
  647. #define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation
  648. #define CODEC_FLAG_CLOSED_GOP 0x80000000
  649. #define CODEC_FLAG2_FAST 0x00000001 ///< Allow non spec compliant speedup tricks.
  650. #define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< Skip bitstream encoding.
  651. #define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< Place global headers at every keyframe instead of in extradata.
  652. #define CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 ///< timecode is in drop frame format. DEPRECATED!!!!
  653. #if FF_API_MPV_GLOBAL_OPTS
  654. #define CODEC_FLAG_CBP_RD 0x04000000 ///< Use rate distortion optimization for cbp.
  655. #define CODEC_FLAG_QP_RD 0x08000000 ///< Use rate distortion optimization for qp selectioon.
  656. #define CODEC_FLAG2_STRICT_GOP 0x00000002 ///< Strictly enforce GOP size.
  657. #define CODEC_FLAG2_SKIP_RD 0x00004000 ///< RD optimal MB level residual skipping
  658. #endif
  659. #define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries.
  660. #define CODEC_FLAG2_SHOW_ALL 0x00400000 ///< Show all frames before the first keyframe
  661. /* Unsupported options :
  662. * Syntax Arithmetic coding (SAC)
  663. * Reference Picture Selection
  664. * Independent Segment Decoding */
  665. /* /Fx */
  666. /* codec capabilities */
  667. #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< Decoder can use draw_horiz_band callback.
  668. /**
  669. * Codec uses get_buffer() for allocating buffers and supports custom allocators.
  670. * If not set, it might not use get_buffer() at all or use operations that
  671. * assume the buffer was allocated by avcodec_default_get_buffer.
  672. */
  673. #define CODEC_CAP_DR1 0x0002
  674. #define CODEC_CAP_TRUNCATED 0x0008
  675. /* Codec can export data for HW decoding (XvMC). */
  676. #define CODEC_CAP_HWACCEL 0x0010
  677. /**
  678. * Encoder or decoder requires flushing with NULL input at the end in order to
  679. * give the complete and correct output.
  680. *
  681. * NOTE: If this flag is not set, the codec is guaranteed to never be fed with
  682. * with NULL data. The user can still send NULL data to the public encode
  683. * or decode function, but libavcodec will not pass it along to the codec
  684. * unless this flag is set.
  685. *
  686. * Decoders:
  687. * The decoder has a non-zero delay and needs to be fed with avpkt->data=NULL,
  688. * avpkt->size=0 at the end to get the delayed data until the decoder no longer
  689. * returns frames.
  690. *
  691. * Encoders:
  692. * The encoder needs to be fed with NULL data at the end of encoding until the
  693. * encoder no longer returns data.
  694. *
  695. * NOTE: For encoders implementing the AVCodec.encode2() function, setting this
  696. * flag also means that the encoder must set the pts and duration for
  697. * each output packet. If this flag is not set, the pts and duration will
  698. * be determined by libavcodec from the input frame.
  699. */
  700. #define CODEC_CAP_DELAY 0x0020
  701. /**
  702. * Codec can be fed a final frame with a smaller size.
  703. * This can be used to prevent truncation of the last audio samples.
  704. */
  705. #define CODEC_CAP_SMALL_LAST_FRAME 0x0040
  706. /**
  707. * Codec can export data for HW decoding (VDPAU).
  708. */
  709. #define CODEC_CAP_HWACCEL_VDPAU 0x0080
  710. /**
  711. * Codec can output multiple frames per AVPacket
  712. * Normally demuxers return one frame at a time, demuxers which do not do
  713. * are connected to a parser to split what they return into proper frames.
  714. * This flag is reserved to the very rare category of codecs which have a
  715. * bitstream that cannot be split into frames without timeconsuming
  716. * operations like full decoding. Demuxers carring such bitstreams thus
  717. * may return multiple frames in a packet. This has many disadvantages like
  718. * prohibiting stream copy in many cases thus it should only be considered
  719. * as a last resort.
  720. */
  721. #define CODEC_CAP_SUBFRAMES 0x0100
  722. /**
  723. * Codec is experimental and is thus avoided in favor of non experimental
  724. * encoders
  725. */
  726. #define CODEC_CAP_EXPERIMENTAL 0x0200
  727. /**
  728. * Codec should fill in channel configuration and samplerate instead of container
  729. */
  730. #define CODEC_CAP_CHANNEL_CONF 0x0400
  731. /**
  732. * Codec is able to deal with negative linesizes
  733. */
  734. #define CODEC_CAP_NEG_LINESIZES 0x0800
  735. /**
  736. * Codec supports frame-level multithreading.
  737. */
  738. #define CODEC_CAP_FRAME_THREADS 0x1000
  739. /**
  740. * Codec supports slice-based (or partition-based) multithreading.
  741. */
  742. #define CODEC_CAP_SLICE_THREADS 0x2000
  743. /**
  744. * Codec supports changed parameters at any point.
  745. */
  746. #define CODEC_CAP_PARAM_CHANGE 0x4000
  747. /**
  748. * Codec supports avctx->thread_count == 0 (auto).
  749. */
  750. #define CODEC_CAP_AUTO_THREADS 0x8000
  751. /**
  752. * Audio encoder supports receiving a different number of samples in each call.
  753. */
  754. #define CODEC_CAP_VARIABLE_FRAME_SIZE 0x10000
  755. /**
  756. * Codec is intra only.
  757. */
  758. #define CODEC_CAP_INTRA_ONLY 0x40000000
  759. /**
  760. * Codec is lossless.
  761. */
  762. #define CODEC_CAP_LOSSLESS 0x80000000
  763. //The following defines may change, don't expect compatibility if you use them.
  764. #define MB_TYPE_INTRA4x4 0x0001
  765. #define MB_TYPE_INTRA16x16 0x0002 //FIXME H.264-specific
  766. #define MB_TYPE_INTRA_PCM 0x0004 //FIXME H.264-specific
  767. #define MB_TYPE_16x16 0x0008
  768. #define MB_TYPE_16x8 0x0010
  769. #define MB_TYPE_8x16 0x0020
  770. #define MB_TYPE_8x8 0x0040
  771. #define MB_TYPE_INTERLACED 0x0080
  772. #define MB_TYPE_DIRECT2 0x0100 //FIXME
  773. #define MB_TYPE_ACPRED 0x0200
  774. #define MB_TYPE_GMC 0x0400
  775. #define MB_TYPE_SKIP 0x0800
  776. #define MB_TYPE_P0L0 0x1000
  777. #define MB_TYPE_P1L0 0x2000
  778. #define MB_TYPE_P0L1 0x4000
  779. #define MB_TYPE_P1L1 0x8000
  780. #define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0)
  781. #define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1)
  782. #define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1)
  783. #define MB_TYPE_QUANT 0x00010000
  784. #define MB_TYPE_CBP 0x00020000
  785. //Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...)
  786. /**
  787. * Pan Scan area.
  788. * This specifies the area which should be displayed.
  789. * Note there may be multiple such areas for one frame.
  790. */
  791. typedef struct AVPanScan{
  792. /**
  793. * id
  794. * - encoding: Set by user.
  795. * - decoding: Set by libavcodec.
  796. */
  797. int id;
  798. /**
  799. * width and height in 1/16 pel
  800. * - encoding: Set by user.
  801. * - decoding: Set by libavcodec.
  802. */
  803. int width;
  804. int height;
  805. /**
  806. * position of the top left corner in 1/16 pel for up to 3 fields/frames
  807. * - encoding: Set by user.
  808. * - decoding: Set by libavcodec.
  809. */
  810. int16_t position[3][2];
  811. }AVPanScan;
  812. #define FF_QSCALE_TYPE_MPEG1 0
  813. #define FF_QSCALE_TYPE_MPEG2 1
  814. #define FF_QSCALE_TYPE_H264 2
  815. #define FF_QSCALE_TYPE_VP56 3
  816. #define FF_BUFFER_TYPE_INTERNAL 1
  817. #define FF_BUFFER_TYPE_USER 2 ///< direct rendering buffers (image is (de)allocated by user)
  818. #define FF_BUFFER_TYPE_SHARED 4 ///< Buffer from somewhere else; don't deallocate image (data/base), all other tables are not shared.
  819. #define FF_BUFFER_TYPE_COPY 8 ///< Just a (modified) copy of some other buffer, don't deallocate anything.
  820. #define FF_BUFFER_HINTS_VALID 0x01 // Buffer hints value is meaningful (if 0 ignore).
  821. #define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer.
  822. #define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content.
  823. #define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update).
  824. /**
  825. * @defgroup lavc_packet AVPacket
  826. *
  827. * Types and functions for working with AVPacket.
  828. * @{
  829. */
  830. enum AVPacketSideDataType {
  831. AV_PKT_DATA_PALETTE,
  832. AV_PKT_DATA_NEW_EXTRADATA,
  833. /**
  834. * An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
  835. * @code
  836. * u32le param_flags
  837. * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT)
  838. * s32le channel_count
  839. * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT)
  840. * u64le channel_layout
  841. * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE)
  842. * s32le sample_rate
  843. * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS)
  844. * s32le width
  845. * s32le height
  846. * @endcode
  847. */
  848. AV_PKT_DATA_PARAM_CHANGE,
  849. /**
  850. * An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of
  851. * structures with info about macroblocks relevant to splitting the
  852. * packet into smaller packets on macroblock edges (e.g. as for RFC 2190).
  853. * That is, it does not necessarily contain info about all macroblocks,
  854. * as long as the distance between macroblocks in the info is smaller
  855. * than the target payload size.
  856. * Each MB info structure is 12 bytes, and is laid out as follows:
  857. * @code
  858. * u32le bit offset from the start of the packet
  859. * u8 current quantizer at the start of the macroblock
  860. * u8 GOB number
  861. * u16le macroblock address within the GOB
  862. * u8 horizontal MV predictor
  863. * u8 vertical MV predictor
  864. * u8 horizontal MV predictor for block number 3
  865. * u8 vertical MV predictor for block number 3
  866. * @endcode
  867. */
  868. AV_PKT_DATA_H263_MB_INFO,
  869. /**
  870. * Recommmends skipping the specified number of samples
  871. * @code
  872. * u32le number of samples to skip from start of this packet
  873. * u32le number of samples to skip from end of this packet
  874. * u8 reason for start skip
  875. * u8 reason for end skip (0=padding silence, 1=convergence)
  876. * @endcode
  877. */
  878. AV_PKT_DATA_SKIP_SAMPLES=70,
  879. /**
  880. * An AV_PKT_DATA_JP_DUALMONO side data packet indicates that
  881. * the packet may contain "dual mono" audio specific to Japanese DTV
  882. * and if it is true, recommends only the selected channel to be used.
  883. * @code
  884. * u8 selected channels (0=mail/left, 1=sub/right, 2=both)
  885. * @endcode
  886. */
  887. AV_PKT_DATA_JP_DUALMONO,
  888. };
  889. typedef struct AVPacket {
  890. /**
  891. * Presentation timestamp in AVStream->time_base units; the time at which
  892. * the decompressed packet will be presented to the user.
  893. * Can be AV_NOPTS_VALUE if it is not stored in the file.
  894. * pts MUST be larger or equal to dts as presentation cannot happen before
  895. * decompression, unless one wants to view hex dumps. Some formats misuse
  896. * the terms dts and pts/cts to mean something different. Such timestamps
  897. * must be converted to true pts/dts before they are stored in AVPacket.
  898. */
  899. int64_t pts;
  900. /**
  901. * Decompression timestamp in AVStream->time_base units; the time at which
  902. * the packet is decompressed.
  903. * Can be AV_NOPTS_VALUE if it is not stored in the file.
  904. */
  905. int64_t dts;
  906. uint8_t *data;
  907. int size;
  908. int stream_index;
  909. /**
  910. * A combination of AV_PKT_FLAG values
  911. */
  912. int flags;
  913. /**
  914. * Additional packet data that can be provided by the container.
  915. * Packet can contain several types of side information.
  916. */
  917. struct {
  918. uint8_t *data;
  919. int size;
  920. enum AVPacketSideDataType type;
  921. } *side_data;
  922. int side_data_elems;
  923. /**
  924. * Duration of this packet in AVStream->time_base units, 0 if unknown.
  925. * Equals next_pts - this_pts in presentation order.
  926. */
  927. int duration;
  928. void (*destruct)(struct AVPacket *);
  929. void *priv;
  930. int64_t pos; ///< byte position in stream, -1 if unknown
  931. /**
  932. * Time difference in AVStream->time_base units from the pts of this
  933. * packet to the point at which the output from the decoder has converged
  934. * independent from the availability of previous frames. That is, the
  935. * frames are virtually identical no matter if decoding started from
  936. * the very first frame or from this keyframe.
  937. * Is AV_NOPTS_VALUE if unknown.
  938. * This field is not the display duration of the current packet.
  939. * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY
  940. * set.
  941. *
  942. * The purpose of this field is to allow seeking in streams that have no
  943. * keyframes in the conventional sense. It corresponds to the
  944. * recovery point SEI in H.264 and match_time_delta in NUT. It is also
  945. * essential for some types of subtitle streams to ensure that all
  946. * subtitles are correctly displayed after seeking.
  947. */
  948. int64_t convergence_duration;
  949. } AVPacket;
  950. #define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe
  951. #define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted
  952. enum AVSideDataParamChangeFlags {
  953. AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT = 0x0001,
  954. AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002,
  955. AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = 0x0004,
  956. AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008,
  957. };
  958. /**
  959. * @}
  960. */
  961. /**
  962. * Audio Video Frame.
  963. * New fields can be added to the end of AVFRAME with minor version
  964. * bumps. Similarly fields that are marked as to be only accessed by
  965. * av_opt_ptr() can be reordered. This allows 2 forks to add fields
  966. * without breaking compatibility with each other.
  967. * Removal, reordering and changes in the remaining cases require
  968. * a major version bump.
  969. * sizeof(AVFrame) must not be used outside libavcodec.
  970. */
  971. typedef struct AVFrame {
  972. #define AV_NUM_DATA_POINTERS 8
  973. /**
  974. * pointer to the picture/channel planes.
  975. * This might be different from the first allocated byte
  976. * - encoding: Set by user
  977. * - decoding: set by AVCodecContext.get_buffer()
  978. */
  979. uint8_t *data[AV_NUM_DATA_POINTERS];
  980. /**
  981. * Size, in bytes, of the data for each picture/channel plane.
  982. *
  983. * For audio, only linesize[0] may be set. For planar audio, each channel
  984. * plane must be the same size.
  985. *
  986. * - encoding: Set by user
  987. * - decoding: set by AVCodecContext.get_buffer()
  988. */
  989. int linesize[AV_NUM_DATA_POINTERS];
  990. /**
  991. * pointers to the data planes/channels.
  992. *
  993. * For video, this should simply point to data[].
  994. *
  995. * For planar audio, each channel has a separate data pointer, and
  996. * linesize[0] contains the size of each channel buffer.
  997. * For packed audio, there is just one data pointer, and linesize[0]
  998. * contains the total size of the buffer for all channels.
  999. *
  1000. * Note: Both data and extended_data will always be set by get_buffer(),
  1001. * but for planar audio with more channels that can fit in data,
  1002. * extended_data must be used by the decoder in order to access all
  1003. * channels.
  1004. *
  1005. * encoding: unused
  1006. * decoding: set by AVCodecContext.get_buffer()
  1007. */
  1008. uint8_t **extended_data;
  1009. /**
  1010. * width and height of the video frame
  1011. * - encoding: unused
  1012. * - decoding: Read by user.
  1013. */
  1014. int width, height;
  1015. /**
  1016. * number of audio samples (per channel) described by this frame
  1017. * - encoding: Set by user
  1018. * - decoding: Set by libavcodec
  1019. */
  1020. int nb_samples;
  1021. /**
  1022. * format of the frame, -1 if unknown or unset
  1023. * Values correspond to enum PixelFormat for video frames,
  1024. * enum AVSampleFormat for audio)
  1025. * - encoding: unused
  1026. * - decoding: Read by user.
  1027. */
  1028. int format;
  1029. /**
  1030. * 1 -> keyframe, 0-> not
  1031. * - encoding: Set by libavcodec.
  1032. * - decoding: Set by libavcodec.
  1033. */
  1034. int key_frame;
  1035. /**
  1036. * Picture type of the frame, see ?_TYPE below.
  1037. * - encoding: Set by libavcodec. for coded_picture (and set by user for input).
  1038. * - decoding: Set by libavcodec.
  1039. */
  1040. enum AVPictureType pict_type;
  1041. /**
  1042. * pointer to the first allocated byte of the picture. Can be used in get_buffer/release_buffer.
  1043. * This isn't used by libavcodec unless the default get/release_buffer() is used.
  1044. * - encoding:
  1045. * - decoding:
  1046. */
  1047. uint8_t *base[AV_NUM_DATA_POINTERS];
  1048. /**
  1049. * sample aspect ratio for the video frame, 0/1 if unknown/unspecified
  1050. * - encoding: unused
  1051. * - decoding: Read by user.
  1052. */
  1053. AVRational sample_aspect_ratio;
  1054. /**
  1055. * presentation timestamp in time_base units (time when frame should be shown to user)
  1056. * If AV_NOPTS_VALUE then frame_rate = 1/time_base will be assumed.
  1057. * - encoding: MUST be set by user.
  1058. * - decoding: Set by libavcodec.
  1059. */
  1060. int64_t pts;
  1061. /**
  1062. * reordered pts from the last AVPacket that has been input into the decoder
  1063. * - encoding: unused
  1064. * - decoding: Read by user.
  1065. */
  1066. int64_t pkt_pts;
  1067. /**
  1068. * dts from the last AVPacket that has been input into the decoder
  1069. * - encoding: unused
  1070. * - decoding: Read by user.
  1071. */
  1072. int64_t pkt_dts;
  1073. /**
  1074. * picture number in bitstream order
  1075. * - encoding: set by
  1076. * - decoding: Set by libavcodec.
  1077. */
  1078. int coded_picture_number;
  1079. /**
  1080. * picture number in display order
  1081. * - encoding: set by
  1082. * - decoding: Set by libavcodec.
  1083. */
  1084. int display_picture_number;
  1085. /**
  1086. * quality (between 1 (good) and FF_LAMBDA_MAX (bad))
  1087. * - encoding: Set by libavcodec. for coded_picture (and set by user for input).
  1088. * - decoding: Set by libavcodec.
  1089. */
  1090. int quality;
  1091. /**
  1092. * is this picture used as reference
  1093. * The values for this are the same as the MpegEncContext.picture_structure
  1094. * variable, that is 1->top field, 2->bottom field, 3->frame/both fields.
  1095. * Set to 4 for delayed, non-reference frames.
  1096. * - encoding: unused
  1097. * - decoding: Set by libavcodec. (before get_buffer() call)).
  1098. */
  1099. int reference;
  1100. /**
  1101. * QP table
  1102. * - encoding: unused
  1103. * - decoding: Set by libavcodec.
  1104. */
  1105. int8_t *qscale_table;
  1106. /**
  1107. * QP store stride
  1108. * - encoding: unused
  1109. * - decoding: Set by libavcodec.
  1110. */
  1111. int qstride;
  1112. /**
  1113. *
  1114. */
  1115. int qscale_type;
  1116. /**
  1117. * mbskip_table[mb]>=1 if MB didn't change
  1118. * stride= mb_width = (width+15)>>4
  1119. * - encoding: unused
  1120. * - decoding: Set by libavcodec.
  1121. */
  1122. uint8_t *mbskip_table;
  1123. /**
  1124. * motion vector table
  1125. * @code
  1126. * example:
  1127. * int mv_sample_log2= 4 - motion_subsample_log2;
  1128. * int mb_width= (width+15)>>4;
  1129. * int mv_stride= (mb_width << mv_sample_log2) + 1;
  1130. * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y];
  1131. * @endcode
  1132. * - encoding: Set by user.
  1133. * - decoding: Set by libavcodec.
  1134. */
  1135. int16_t (*motion_val[2])[2];
  1136. /**
  1137. * macroblock type table
  1138. * mb_type_base + mb_width + 2
  1139. * - encoding: Set by user.
  1140. * - decoding: Set by libavcodec.
  1141. */
  1142. uint32_t *mb_type;
  1143. /**
  1144. * DCT coefficients
  1145. * - encoding: unused
  1146. * - decoding: Set by libavcodec.
  1147. */
  1148. short *dct_coeff;
  1149. /**
  1150. * motion reference frame index
  1151. * the order in which these are stored can depend on the codec.
  1152. * - encoding: Set by user.
  1153. * - decoding: Set by libavcodec.
  1154. */
  1155. int8_t *ref_index[2];
  1156. /**
  1157. * for some private data of the user
  1158. * - encoding: unused
  1159. * - decoding: Set by user.
  1160. */
  1161. void *opaque;
  1162. /**
  1163. * error
  1164. * - encoding: Set by libavcodec. if flags&CODEC_FLAG_PSNR.
  1165. * - decoding: unused
  1166. */
  1167. uint64_t error[AV_NUM_DATA_POINTERS];
  1168. /**
  1169. * type of the buffer (to keep track of who has to deallocate data[*])
  1170. * - encoding: Set by the one who allocates it.
  1171. * - decoding: Set by the one who allocates it.
  1172. * Note: User allocated (direct rendering) & internal buffers cannot coexist currently.
  1173. */
  1174. int type;
  1175. /**
  1176. * When decoding, this signals how much the picture must be delayed.
  1177. * extra_delay = repeat_pict / (2*fps)
  1178. * - encoding: unused
  1179. * - decoding: Set by libavcodec.
  1180. */
  1181. int repeat_pict;
  1182. /**
  1183. * The content of the picture is interlaced.
  1184. * - encoding: Set by user.
  1185. * - decoding: Set by libavcodec. (default 0)
  1186. */
  1187. int interlaced_frame;
  1188. /**
  1189. * If the content is interlaced, is top field displayed first.
  1190. * - encoding: Set by user.
  1191. * - decoding: Set by libavcodec.
  1192. */
  1193. int top_field_first;
  1194. /**
  1195. * Tell user application that palette has changed from previous frame.
  1196. * - encoding: ??? (no palette-enabled encoder yet)
  1197. * - decoding: Set by libavcodec. (default 0).
  1198. */
  1199. int palette_has_changed;
  1200. /**
  1201. * codec suggestion on buffer type if != 0
  1202. * - encoding: unused
  1203. * - decoding: Set by libavcodec. (before get_buffer() call)).
  1204. */
  1205. int buffer_hints;
  1206. /**
  1207. * Pan scan.
  1208. * - encoding: Set by user.
  1209. * - decoding: Set by libavcodec.
  1210. */
  1211. AVPanScan *pan_scan;
  1212. /**
  1213. * reordered opaque 64bit (generally an integer or a double precision float
  1214. * PTS but can be anything).
  1215. * The user sets AVCodecContext.reordered_opaque to represent the input at
  1216. * that time,
  1217. * the decoder reorders values as needed and sets AVFrame.reordered_opaque
  1218. * to exactly one of the values provided by the user through AVCodecContext.reordered_opaque
  1219. * @deprecated in favor of pkt_pts
  1220. * - encoding: unused
  1221. * - decoding: Read by user.
  1222. */
  1223. int64_t reordered_opaque;
  1224. /**
  1225. * hardware accelerator private data (FFmpeg-allocated)
  1226. * - encoding: unused
  1227. * - decoding: Set by libavcodec
  1228. */
  1229. void *hwaccel_picture_private;
  1230. /**
  1231. * the AVCodecContext which ff_thread_get_buffer() was last called on
  1232. * - encoding: Set by libavcodec.
  1233. * - decoding: Set by libavcodec.
  1234. */
  1235. struct AVCodecContext *owner;
  1236. /**
  1237. * used by multithreading to store frame-specific info
  1238. * - encoding: Set by libavcodec.
  1239. * - decoding: Set by libavcodec.
  1240. */
  1241. void *thread_opaque;
  1242. /**
  1243. * log2 of the size of the block which a single vector in motion_val represents:
  1244. * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2)
  1245. * - encoding: unused
  1246. * - decoding: Set by libavcodec.
  1247. */
  1248. uint8_t motion_subsample_log2;
  1249. /**
  1250. * Sample rate of the audio data.
  1251. *
  1252. * - encoding: unused
  1253. * - decoding: read by user
  1254. */
  1255. int sample_rate;
  1256. /**
  1257. * Channel layout of the audio data.
  1258. *
  1259. * - encoding: unused
  1260. * - decoding: read by user.
  1261. */
  1262. uint64_t channel_layout;
  1263. /**
  1264. * frame timestamp estimated using various heuristics, in stream time base
  1265. * Code outside libavcodec should access this field using:
  1266. * av_frame_get_best_effort_timestamp(frame)
  1267. * - encoding: unused
  1268. * - decoding: set by libavcodec, read by user.
  1269. */
  1270. int64_t best_effort_timestamp;
  1271. /**
  1272. * reordered pos from the last AVPacket that has been input into the decoder
  1273. * Code outside libavcodec should access this field using:
  1274. * av_frame_get_pkt_pos(frame)
  1275. * - encoding: unused
  1276. * - decoding: Read by user.
  1277. */
  1278. int64_t pkt_pos;
  1279. /**
  1280. * duration of the corresponding packet, expressed in
  1281. * AVStream->time_base units, 0 if unknown.
  1282. * Code outside libavcodec should access this field using:
  1283. * av_frame_get_pkt_duration(frame)
  1284. * - encoding: unused
  1285. * - decoding: Read by user.
  1286. */
  1287. int64_t pkt_duration;
  1288. /**
  1289. * metadata.
  1290. * Code outside libavcodec should access this field using:
  1291. * av_frame_get_metadata(frame)
  1292. * - encoding: Set by user.
  1293. * - decoding: Set by libavcodec.
  1294. */
  1295. AVDictionary *metadata;
  1296. /**
  1297. * decode error flags of the frame, set to a combination of
  1298. * FF_DECODE_ERROR_xxx flags if the decoder produced a frame, but there
  1299. * were errors during the decoding.
  1300. * Code outside libavcodec should access this field using:
  1301. * av_frame_get_decode_error_flags(frame)
  1302. * - encoding: unused
  1303. * - decoding: set by libavcodec, read by user.
  1304. */
  1305. int decode_error_flags;
  1306. #define FF_DECODE_ERROR_INVALID_BITSTREAM 1
  1307. #define FF_DECODE_ERROR_MISSING_REFERENCE 2
  1308. /**
  1309. * number of audio channels, only used for audio.
  1310. * Code outside libavcodec should access this field using:
  1311. * av_frame_get_channels(frame)
  1312. * - encoding: unused
  1313. * - decoding: Read by user.
  1314. */
  1315. int64_t channels;
  1316. } AVFrame;
  1317. /**
  1318. * Accessors for some AVFrame fields.
  1319. * The position of these field in the structure is not part of the ABI,
  1320. * they should not be accessed directly outside libavcodec.
  1321. */
  1322. int64_t av_frame_get_best_effort_timestamp(const AVFrame *frame);
  1323. void av_frame_set_best_effort_timestamp(AVFrame *frame, int64_t val);
  1324. int64_t av_frame_get_pkt_duration (const AVFrame *frame);
  1325. void av_frame_set_pkt_duration (AVFrame *frame, int64_t val);
  1326. int64_t av_frame_get_pkt_pos (const AVFrame *frame);
  1327. void av_frame_set_pkt_pos (AVFrame *frame, int64_t val);
  1328. int64_t av_frame_get_channel_layout (const AVFrame *frame);
  1329. void av_frame_set_channel_layout (AVFrame *frame, int64_t val);
  1330. int av_frame_get_channels (const AVFrame *frame);
  1331. void av_frame_set_channels (AVFrame *frame, int val);
  1332. int av_frame_get_sample_rate (const AVFrame *frame);
  1333. void av_frame_set_sample_rate (AVFrame *frame, int val);
  1334. AVDictionary *av_frame_get_metadata (const AVFrame *frame);
  1335. void av_frame_set_metadata (AVFrame *frame, AVDictionary *val);
  1336. int av_frame_get_decode_error_flags (const AVFrame *frame);
  1337. void av_frame_set_decode_error_flags (AVFrame *frame, int val);
  1338. struct AVCodecInternal;
  1339. enum AVFieldOrder {
  1340. AV_FIELD_UNKNOWN,
  1341. AV_FIELD_PROGRESSIVE,
  1342. AV_FIELD_TT, //< Top coded_first, top displayed first
  1343. AV_FIELD_BB, //< Bottom coded first, bottom displayed first
  1344. AV_FIELD_TB, //< Top coded first, bottom displayed first
  1345. AV_FIELD_BT, //< Bottom coded first, top displayed first
  1346. };
  1347. /**
  1348. * main external API structure.
  1349. * New fields can be added to the end with minor version bumps.
  1350. * Removal, reordering and changes to existing fields require a major
  1351. * version bump.
  1352. * Please use AVOptions (av_opt* / av_set/get*()) to access these fields from user
  1353. * applications.
  1354. * sizeof(AVCodecContext) must not be used outside libav*.
  1355. */
  1356. typedef struct AVCodecContext {
  1357. /**
  1358. * information on struct for av_log
  1359. * - set by avcodec_alloc_context3
  1360. */
  1361. const AVClass *av_class;
  1362. int log_level_offset;
  1363. enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */
  1364. const struct AVCodec *codec;
  1365. char codec_name[32];
  1366. enum AVCodecID codec_id; /* see AV_CODEC_ID_xxx */
  1367. /**
  1368. * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
  1369. * This is used to work around some encoder bugs.
  1370. * A demuxer should set this to what is stored in the field used to identify the codec.
  1371. * If there are multiple such fields in a container then the demuxer should choose the one
  1372. * which maximizes the information about the used codec.
  1373. * If the codec tag field in a container is larger than 32 bits then the demuxer should
  1374. * remap the longer ID to 32 bits with a table or other structure. Alternatively a new
  1375. * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated
  1376. * first.
  1377. * - encoding: Set by user, if not then the default based on codec_id will be used.
  1378. * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
  1379. */
  1380. unsigned int codec_tag;
  1381. /**
  1382. * fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
  1383. * This is used to work around some encoder bugs.
  1384. * - encoding: unused
  1385. * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
  1386. */
  1387. unsigned int stream_codec_tag;
  1388. #if FF_API_SUB_ID
  1389. /**
  1390. * @deprecated this field is unused
  1391. */
  1392. attribute_deprecated int sub_id;
  1393. #endif
  1394. void *priv_data;
  1395. /**
  1396. * Private context used for internal data.
  1397. *
  1398. * Unlike priv_data, this is not codec-specific. It is used in general
  1399. * libavcodec functions.
  1400. */
  1401. struct AVCodecInternal *internal;
  1402. /**
  1403. * Private data of the user, can be used to carry app specific stuff.
  1404. * - encoding: Set by user.
  1405. * - decoding: Set by user.
  1406. */
  1407. void *opaque;
  1408. /**
  1409. * the average bitrate
  1410. * - encoding: Set by user; unused for constant quantizer encoding.
  1411. * - decoding: Set by libavcodec. 0 or some bitrate if this info is available in the stream.
  1412. */
  1413. int bit_rate;
  1414. /**
  1415. * number of bits the bitstream is allowed to diverge from the reference.
  1416. * the reference can be CBR (for CBR pass1) or VBR (for pass2)
  1417. * - encoding: Set by user; unused for constant quantizer encoding.
  1418. * - decoding: unused
  1419. */
  1420. int bit_rate_tolerance;
  1421. /**
  1422. * Global quality for codecs which cannot change it per frame.
  1423. * This should be proportional to MPEG-1/2/4 qscale.
  1424. * - encoding: Set by user.
  1425. * - decoding: unused
  1426. */
  1427. int global_quality;
  1428. /**
  1429. * - encoding: Set by user.
  1430. * - decoding: unused
  1431. */
  1432. int compression_level;
  1433. #define FF_COMPRESSION_DEFAULT -1
  1434. /**
  1435. * CODEC_FLAG_*.
  1436. * - encoding: Set by user.
  1437. * - decoding: Set by user.
  1438. */
  1439. int flags;
  1440. /**
  1441. * CODEC_FLAG2_*
  1442. * - encoding: Set by user.
  1443. * - decoding: Set by user.
  1444. */
  1445. int flags2;
  1446. /**
  1447. * some codecs need / can use extradata like Huffman tables.
  1448. * mjpeg: Huffman tables
  1449. * rv10: additional flags
  1450. * mpeg4: global headers (they can be in the bitstream or here)
  1451. * The allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger
  1452. * than extradata_size to avoid prolems if it is read with the bitstream reader.
  1453. * The bytewise contents of extradata must not depend on the architecture or CPU endianness.
  1454. * - encoding: Set/allocated/freed by libavcodec.
  1455. * - decoding: Set/allocated/freed by user.
  1456. */
  1457. uint8_t *extradata;
  1458. int extradata_size;
  1459. /**
  1460. * This is the fundamental unit of time (in seconds) in terms
  1461. * of which frame timestamps are represented. For fixed-fps content,
  1462. * timebase should be 1/framerate and timestamp increments should be
  1463. * identically 1.
  1464. * - encoding: MUST be set by user.
  1465. * - decoding: Set by libavcodec.
  1466. */
  1467. AVRational time_base;
  1468. /**
  1469. * For some codecs, the time base is closer to the field rate than the frame rate.
  1470. * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration
  1471. * if no telecine is used ...
  1472. *
  1473. * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2.
  1474. */
  1475. int ticks_per_frame;
  1476. /**
  1477. * Encoding: Number of frames delay there will be from the encoder input to
  1478. * the decoder output. (we assume the decoder matches the spec)
  1479. * Decoding: Number of frames delay in addition to what a standard decoder
  1480. * as specified in the spec would produce.
  1481. *
  1482. * Video:
  1483. * Number of frames the decoded output will be delayed relative to the
  1484. * encoded input.
  1485. *
  1486. * Audio:
  1487. * For encoding, this is the number of "priming" samples added to the
  1488. * beginning of the stream. The decoded output will be delayed by this
  1489. * many samples relative to the input to the encoder. Note that this
  1490. * field is purely informational and does not directly affect the pts
  1491. * output by the encoder, which should always be based on the actual
  1492. * presentation time, including any delay.
  1493. * For decoding, this is the number of samples the decoder needs to
  1494. * output before the decoder's output is valid. When seeking, you should
  1495. * start decoding this many samples prior to your desired seek point.
  1496. *
  1497. * - encoding: Set by libavcodec.
  1498. * - decoding: Set by libavcodec.
  1499. */
  1500. int delay;
  1501. /* video only */
  1502. /**
  1503. * picture width / height.
  1504. * - encoding: MUST be set by user.
  1505. * - decoding: Set by libavcodec.
  1506. * Note: For compatibility it is possible to set this instead of
  1507. * coded_width/height before decoding.
  1508. */
  1509. int width, height;
  1510. /**
  1511. * Bitstream width / height, may be different from width/height if lowres enabled.
  1512. * - encoding: unused
  1513. * - decoding: Set by user before init if known. Codec should override / dynamically change if needed.
  1514. */
  1515. int coded_width, coded_height;
  1516. #define FF_ASPECT_EXTENDED 15
  1517. /**
  1518. * the number of pictures in a group of pictures, or 0 for intra_only
  1519. * - encoding: Set by user.
  1520. * - decoding: unused
  1521. */
  1522. int gop_size;
  1523. /**
  1524. * Pixel format, see PIX_FMT_xxx.
  1525. * May be set by the demuxer if known from headers.
  1526. * May be overridden by the decoder if it knows better.
  1527. * - encoding: Set by user.
  1528. * - decoding: Set by user if known, overridden by libavcodec if known
  1529. */
  1530. enum PixelFormat pix_fmt;
  1531. /**
  1532. * Motion estimation algorithm used for video coding.
  1533. * 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex),
  1534. * 8 (umh), 9 (iter), 10 (tesa) [7, 8, 10 are x264 specific, 9 is snow specific]
  1535. * - encoding: MUST be set by user.
  1536. * - decoding: unused
  1537. */
  1538. int me_method;
  1539. /**
  1540. * If non NULL, 'draw_horiz_band' is called by the libavcodec
  1541. * decoder to draw a horizontal band. It improves cache usage. Not
  1542. * all codecs can do that. You must check the codec capabilities
  1543. * beforehand.
  1544. * When multithreading is used, it may be called from multiple threads
  1545. * at the same time; threads might draw different parts of the same AVFrame,
  1546. * or multiple AVFrames, and there is no guarantee that slices will be drawn
  1547. * in order.
  1548. * The function is also used by hardware acceleration APIs.
  1549. * It is called at least once during frame decoding to pass
  1550. * the data needed for hardware render.
  1551. * In that mode instead of pixel data, AVFrame points to
  1552. * a structure specific to the acceleration API. The application
  1553. * reads the structure and can change some fields to indicate progress
  1554. * or mark state.
  1555. * - encoding: unused
  1556. * - decoding: Set by user.
  1557. * @param height the height of the slice
  1558. * @param y the y position of the slice
  1559. * @param type 1->top field, 2->bottom field, 3->frame
  1560. * @param offset offset into the AVFrame.data from which the slice should be read
  1561. */
  1562. void (*draw_horiz_band)(struct AVCodecContext *s,
  1563. const AVFrame *src, int offset[AV_NUM_DATA_POINTERS],
  1564. int y, int type, int height);
  1565. /**
  1566. * callback to negotiate the pixelFormat
  1567. * @param fmt is the list of formats which are supported by the codec,
  1568. * it is terminated by -1 as 0 is a valid format, the formats are ordered by quality.
  1569. * The first is always the native one.
  1570. * @return the chosen format
  1571. * - encoding: unused
  1572. * - decoding: Set by user, if not set the native format will be chosen.
  1573. */
  1574. enum PixelFormat (*get_format)(struct AVCodecContext *s, const enum PixelFormat * fmt);
  1575. /**
  1576. * maximum number of B-frames between non-B-frames
  1577. * Note: The output will be delayed by max_b_frames+1 relative to the input.
  1578. * - encoding: Set by user.
  1579. * - decoding: unused
  1580. */
  1581. int max_b_frames;
  1582. /**
  1583. * qscale factor between IP and B-frames
  1584. * If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset).
  1585. * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
  1586. * - encoding: Set by user.
  1587. * - decoding: unused
  1588. */
  1589. float b_quant_factor;
  1590. /** obsolete FIXME remove */
  1591. int rc_strategy;
  1592. #define FF_RC_STRATEGY_XVID 1
  1593. int b_frame_strategy;
  1594. #if FF_API_MPV_GLOBAL_OPTS
  1595. /**
  1596. * luma single coefficient elimination threshold
  1597. * - encoding: Set by user.
  1598. * - decoding: unused
  1599. */
  1600. attribute_deprecated int luma_elim_threshold;
  1601. /**
  1602. * chroma single coeff elimination threshold
  1603. * - encoding: Set by user.
  1604. * - decoding: unused
  1605. */
  1606. attribute_deprecated int chroma_elim_threshold;
  1607. #endif
  1608. /**
  1609. * qscale offset between IP and B-frames
  1610. * - encoding: Set by user.
  1611. * - decoding: unused
  1612. */
  1613. float b_quant_offset;
  1614. /**
  1615. * Size of the frame reordering buffer in the decoder.
  1616. * For MPEG-2 it is 1 IPB or 0 low delay IP.
  1617. * - encoding: Set by libavcodec.
  1618. * - decoding: Set by libavcodec.
  1619. */
  1620. int has_b_frames;
  1621. /**
  1622. * 0-> h263 quant 1-> mpeg quant
  1623. * - encoding: Set by user.
  1624. * - decoding: unused
  1625. */
  1626. int mpeg_quant;
  1627. /**
  1628. * qscale factor between P and I-frames
  1629. * If > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset).
  1630. * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
  1631. * - encoding: Set by user.
  1632. * - decoding: unused
  1633. */
  1634. float i_quant_factor;
  1635. /**
  1636. * qscale offset between P and I-frames
  1637. * - encoding: Set by user.
  1638. * - decoding: unused
  1639. */
  1640. float i_quant_offset;
  1641. /**
  1642. * luminance masking (0-> disabled)
  1643. * - encoding: Set by user.
  1644. * - decoding: unused
  1645. */
  1646. float lumi_masking;
  1647. /**
  1648. * temporary complexity masking (0-> disabled)
  1649. * - encoding: Set by user.
  1650. * - decoding: unused
  1651. */
  1652. float temporal_cplx_masking;
  1653. /**
  1654. * spatial complexity masking (0-> disabled)
  1655. * - encoding: Set by user.
  1656. * - decoding: unused
  1657. */
  1658. float spatial_cplx_masking;
  1659. /**
  1660. * p block masking (0-> disabled)
  1661. * - encoding: Set by user.
  1662. * - decoding: unused
  1663. */
  1664. float p_masking;
  1665. /**
  1666. * darkness masking (0-> disabled)
  1667. * - encoding: Set by user.
  1668. * - decoding: unused
  1669. */
  1670. float dark_masking;
  1671. /**
  1672. * slice count
  1673. * - encoding: Set by libavcodec.
  1674. * - decoding: Set by user (or 0).
  1675. */
  1676. int slice_count;
  1677. /**
  1678. * prediction method (needed for huffyuv)
  1679. * - encoding: Set by user.
  1680. * - decoding: unused
  1681. */
  1682. int prediction_method;
  1683. #define FF_PRED_LEFT 0
  1684. #define FF_PRED_PLANE 1
  1685. #define FF_PRED_MEDIAN 2
  1686. /**
  1687. * slice offsets in the frame in bytes
  1688. * - encoding: Set/allocated by libavcodec.
  1689. * - decoding: Set/allocated by user (or NULL).
  1690. */
  1691. int *slice_offset;
  1692. /**
  1693. * sample aspect ratio (0 if unknown)
  1694. * That is the width of a pixel divided by the height of the pixel.
  1695. * Numerator and denominator must be relatively prime and smaller than 256 for some video standards.
  1696. * - encoding: Set by user.
  1697. * - decoding: Set by libavcodec.
  1698. */
  1699. AVRational sample_aspect_ratio;
  1700. /**
  1701. * motion estimation comparison function
  1702. * - encoding: Set by user.
  1703. * - decoding: unused
  1704. */
  1705. int me_cmp;
  1706. /**
  1707. * subpixel motion estimation comparison function
  1708. * - encoding: Set by user.
  1709. * - decoding: unused
  1710. */
  1711. int me_sub_cmp;
  1712. /**
  1713. * macroblock comparison function (not supported yet)
  1714. * - encoding: Set by user.
  1715. * - decoding: unused
  1716. */
  1717. int mb_cmp;
  1718. /**
  1719. * interlaced DCT comparison function
  1720. * - encoding: Set by user.
  1721. * - decoding: unused
  1722. */
  1723. int ildct_cmp;
  1724. #define FF_CMP_SAD 0
  1725. #define FF_CMP_SSE 1
  1726. #define FF_CMP_SATD 2
  1727. #define FF_CMP_DCT 3
  1728. #define FF_CMP_PSNR 4
  1729. #define FF_CMP_BIT 5
  1730. #define FF_CMP_RD 6
  1731. #define FF_CMP_ZERO 7
  1732. #define FF_CMP_VSAD 8
  1733. #define FF_CMP_VSSE 9
  1734. #define FF_CMP_NSSE 10
  1735. #define FF_CMP_W53 11
  1736. #define FF_CMP_W97 12
  1737. #define FF_CMP_DCTMAX 13
  1738. #define FF_CMP_DCT264 14
  1739. #define FF_CMP_CHROMA 256
  1740. /**
  1741. * ME diamond size & shape
  1742. * - encoding: Set by user.
  1743. * - decoding: unused
  1744. */
  1745. int dia_size;
  1746. /**
  1747. * amount of previous MV predictors (2a+1 x 2a+1 square)
  1748. * - encoding: Set by user.
  1749. * - decoding: unused
  1750. */
  1751. int last_predictor_count;
  1752. /**
  1753. * prepass for motion estimation
  1754. * - encoding: Set by user.
  1755. * - decoding: unused
  1756. */
  1757. int pre_me;
  1758. /**
  1759. * motion estimation prepass comparison function
  1760. * - encoding: Set by user.
  1761. * - decoding: unused
  1762. */
  1763. int me_pre_cmp;
  1764. /**
  1765. * ME prepass diamond size & shape
  1766. * - encoding: Set by user.
  1767. * - decoding: unused
  1768. */
  1769. int pre_dia_size;
  1770. /**
  1771. * subpel ME quality
  1772. * - encoding: Set by user.
  1773. * - decoding: unused
  1774. */
  1775. int me_subpel_quality;
  1776. /**
  1777. * DTG active format information (additional aspect ratio
  1778. * information only used in DVB MPEG-2 transport streams)
  1779. * 0 if not set.
  1780. *
  1781. * - encoding: unused
  1782. * - decoding: Set by decoder.
  1783. */
  1784. int dtg_active_format;
  1785. #define FF_DTG_AFD_SAME 8
  1786. #define FF_DTG_AFD_4_3 9
  1787. #define FF_DTG_AFD_16_9 10
  1788. #define FF_DTG_AFD_14_9 11
  1789. #define FF_DTG_AFD_4_3_SP_14_9 13
  1790. #define FF_DTG_AFD_16_9_SP_14_9 14
  1791. #define FF_DTG_AFD_SP_4_3 15
  1792. /**
  1793. * maximum motion estimation search range in subpel units
  1794. * If 0 then no limit.
  1795. *
  1796. * - encoding: Set by user.
  1797. * - decoding: unused
  1798. */
  1799. int me_range;
  1800. /**
  1801. * intra quantizer bias
  1802. * - encoding: Set by user.
  1803. * - decoding: unused
  1804. */
  1805. int intra_quant_bias;
  1806. #define FF_DEFAULT_QUANT_BIAS 999999
  1807. /**
  1808. * inter quantizer bias
  1809. * - encoding: Set by user.
  1810. * - decoding: unused
  1811. */
  1812. int inter_quant_bias;
  1813. #if FF_API_COLOR_TABLE_ID
  1814. /**
  1815. * color table ID
  1816. * - encoding: unused
  1817. * - decoding: Which clrtable should be used for 8bit RGB images.
  1818. * Tables have to be stored somewhere. FIXME
  1819. */
  1820. attribute_deprecated int color_table_id;
  1821. #endif
  1822. /**
  1823. * slice flags
  1824. * - encoding: unused
  1825. * - decoding: Set by user.
  1826. */
  1827. int slice_flags;
  1828. #define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display
  1829. #define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
  1830. #define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
  1831. /**
  1832. * XVideo Motion Acceleration
  1833. * - encoding: forbidden
  1834. * - decoding: set by decoder
  1835. */
  1836. int xvmc_acceleration;
  1837. /**
  1838. * macroblock decision mode
  1839. * - encoding: Set by user.
  1840. * - decoding: unused
  1841. */
  1842. int mb_decision;
  1843. #define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp
  1844. #define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits
  1845. #define FF_MB_DECISION_RD 2 ///< rate distortion
  1846. /**
  1847. * custom intra quantization matrix
  1848. * - encoding: Set by user, can be NULL.
  1849. * - decoding: Set by libavcodec.
  1850. */
  1851. uint16_t *intra_matrix;
  1852. /**
  1853. * custom inter quantization matrix
  1854. * - encoding: Set by user, can be NULL.
  1855. * - decoding: Set by libavcodec.
  1856. */
  1857. uint16_t *inter_matrix;
  1858. /**
  1859. * scene change detection threshold
  1860. * 0 is default, larger means fewer detected scene changes.
  1861. * - encoding: Set by user.
  1862. * - decoding: unused
  1863. */
  1864. int scenechange_threshold;
  1865. /**
  1866. * noise reduction strength
  1867. * - encoding: Set by user.
  1868. * - decoding: unused
  1869. */
  1870. int noise_reduction;
  1871. #if FF_API_INTER_THRESHOLD
  1872. /**
  1873. * @deprecated this field is unused
  1874. */
  1875. attribute_deprecated int inter_threshold;
  1876. #endif
  1877. #if FF_API_MPV_GLOBAL_OPTS
  1878. /**
  1879. * @deprecated use mpegvideo private options instead
  1880. */
  1881. attribute_deprecated int quantizer_noise_shaping;
  1882. #endif
  1883. /**
  1884. * Motion estimation threshold below which no motion estimation is
  1885. * performed, but instead the user specified motion vectors are used.
  1886. *
  1887. * - encoding: Set by user.
  1888. * - decoding: unused
  1889. */
  1890. int me_threshold;
  1891. /**
  1892. * Macroblock threshold below which the user specified macroblock types will be used.
  1893. * - encoding: Set by user.
  1894. * - decoding: unused
  1895. */
  1896. int mb_threshold;
  1897. /**
  1898. * precision of the intra DC coefficient - 8
  1899. * - encoding: Set by user.
  1900. * - decoding: unused
  1901. */
  1902. int intra_dc_precision;
  1903. /**
  1904. * Number of macroblock rows at the top which are skipped.
  1905. * - encoding: unused
  1906. * - decoding: Set by user.
  1907. */
  1908. int skip_top;
  1909. /**
  1910. * Number of macroblock rows at the bottom which are skipped.
  1911. * - encoding: unused
  1912. * - decoding: Set by user.
  1913. */
  1914. int skip_bottom;
  1915. /**
  1916. * Border processing masking, raises the quantizer for mbs on the borders
  1917. * of the picture.
  1918. * - encoding: Set by user.
  1919. * - decoding: unused
  1920. */
  1921. float border_masking;
  1922. /**
  1923. * minimum MB lagrange multipler
  1924. * - encoding: Set by user.
  1925. * - decoding: unused
  1926. */
  1927. int mb_lmin;
  1928. /**
  1929. * maximum MB lagrange multipler
  1930. * - encoding: Set by user.
  1931. * - decoding: unused
  1932. */
  1933. int mb_lmax;
  1934. /**
  1935. *
  1936. * - encoding: Set by user.
  1937. * - decoding: unused
  1938. */
  1939. int me_penalty_compensation;
  1940. /**
  1941. *
  1942. * - encoding: Set by user.
  1943. * - decoding: unused
  1944. */
  1945. int bidir_refine;
  1946. /**
  1947. *
  1948. * - encoding: Set by user.
  1949. * - decoding: unused
  1950. */
  1951. int brd_scale;
  1952. /**
  1953. * minimum GOP size
  1954. * - encoding: Set by user.
  1955. * - decoding: unused
  1956. */
  1957. int keyint_min;
  1958. /**
  1959. * number of reference frames
  1960. * - encoding: Set by user.
  1961. * - decoding: Set by lavc.
  1962. */
  1963. int refs;
  1964. /**
  1965. * chroma qp offset from luma
  1966. * - encoding: Set by user.
  1967. * - decoding: unused
  1968. */
  1969. int chromaoffset;
  1970. /**
  1971. * Multiplied by qscale for each frame and added to scene_change_score.
  1972. * - encoding: Set by user.
  1973. * - decoding: unused
  1974. */
  1975. int scenechange_factor;
  1976. /**
  1977. *
  1978. * Note: Value depends upon the compare function used for fullpel ME.
  1979. * - encoding: Set by user.
  1980. * - decoding: unused
  1981. */
  1982. int mv0_threshold;
  1983. /**
  1984. * Adjust sensitivity of b_frame_strategy 1.
  1985. * - encoding: Set by user.
  1986. * - decoding: unused
  1987. */
  1988. int b_sensitivity;
  1989. /**
  1990. * Chromaticity coordinates of the source primaries.
  1991. * - encoding: Set by user
  1992. * - decoding: Set by libavcodec
  1993. */
  1994. enum AVColorPrimaries color_primaries;
  1995. /**
  1996. * Color Transfer Characteristic.
  1997. * - encoding: Set by user
  1998. * - decoding: Set by libavcodec
  1999. */
  2000. enum AVColorTransferCharacteristic color_trc;
  2001. /**
  2002. * YUV colorspace type.
  2003. * - encoding: Set by user
  2004. * - decoding: Set by libavcodec
  2005. */
  2006. enum AVColorSpace colorspace;
  2007. /**
  2008. * MPEG vs JPEG YUV range.
  2009. * - encoding: Set by user
  2010. * - decoding: Set by libavcodec
  2011. */
  2012. enum AVColorRange color_range;
  2013. /**
  2014. * This defines the location of chroma samples.
  2015. * - encoding: Set by user
  2016. * - decoding: Set by libavcodec
  2017. */
  2018. enum AVChromaLocation chroma_sample_location;
  2019. /**
  2020. * Number of slices.
  2021. * Indicates number of picture subdivisions. Used for parallelized
  2022. * decoding.
  2023. * - encoding: Set by user
  2024. * - decoding: unused
  2025. */
  2026. int slices;
  2027. /** Field order
  2028. * - encoding: set by libavcodec
  2029. * - decoding: Set by libavcodec
  2030. */
  2031. enum AVFieldOrder field_order;
  2032. /* audio only */
  2033. int sample_rate; ///< samples per second
  2034. int channels; ///< number of audio channels
  2035. /**
  2036. * audio sample format
  2037. * - encoding: Set by user.
  2038. * - decoding: Set by libavcodec.
  2039. */
  2040. enum AVSampleFormat sample_fmt; ///< sample format
  2041. /* The following data should not be initialized. */
  2042. /**
  2043. * Samples per packet, initialized when calling 'init'.
  2044. */
  2045. int frame_size;
  2046. /**
  2047. * Frame counter, set by libavcodec.
  2048. *
  2049. * - decoding: total number of frames returned from the decoder so far.
  2050. * - encoding: total number of frames passed to the encoder so far.
  2051. *
  2052. * @note the counter is not incremented if encoding/decoding resulted in
  2053. * an error.
  2054. */
  2055. int frame_number;
  2056. /**
  2057. * number of bytes per packet if constant and known or 0
  2058. * Used by some WAV based audio codecs.
  2059. */
  2060. int block_align;
  2061. /**
  2062. * Audio cutoff bandwidth (0 means "automatic")
  2063. * - encoding: Set by user.
  2064. * - decoding: unused
  2065. */
  2066. int cutoff;
  2067. #if FF_API_REQUEST_CHANNELS
  2068. /**
  2069. * Decoder should decode to this many channels if it can (0 for default)
  2070. * - encoding: unused
  2071. * - decoding: Set by user.
  2072. * @deprecated Deprecated in favor of request_channel_layout.
  2073. */
  2074. int request_channels;
  2075. #endif
  2076. /**
  2077. * Audio channel layout.
  2078. * - encoding: set by user.
  2079. * - decoding: set by user, may be overwritten by libavcodec.
  2080. */
  2081. uint64_t channel_layout;
  2082. /**
  2083. * Request decoder to use this channel layout if it can (0 for default)
  2084. * - encoding: unused
  2085. * - decoding: Set by user.
  2086. */
  2087. uint64_t request_channel_layout;
  2088. /**
  2089. * Type of service that the audio stream conveys.
  2090. * - encoding: Set by user.
  2091. * - decoding: Set by libavcodec.
  2092. */
  2093. enum AVAudioServiceType audio_service_type;
  2094. /**
  2095. * desired sample format
  2096. * - encoding: Not used.
  2097. * - decoding: Set by user.
  2098. * Decoder will decode to this format if it can.
  2099. */
  2100. enum AVSampleFormat request_sample_fmt;
  2101. /**
  2102. * Called at the beginning of each frame to get a buffer for it.
  2103. *
  2104. * The function will set AVFrame.data[], AVFrame.linesize[].
  2105. * AVFrame.extended_data[] must also be set, but it should be the same as
  2106. * AVFrame.data[] except for planar audio with more channels than can fit
  2107. * in AVFrame.data[]. In that case, AVFrame.data[] shall still contain as
  2108. * many data pointers as it can hold.
  2109. *
  2110. * if CODEC_CAP_DR1 is not set then get_buffer() must call
  2111. * avcodec_default_get_buffer() instead of providing buffers allocated by
  2112. * some other means.
  2113. *
  2114. * AVFrame.data[] should be 32- or 16-byte-aligned unless the CPU doesn't
  2115. * need it. avcodec_default_get_buffer() aligns the output buffer properly,
  2116. * but if get_buffer() is overridden then alignment considerations should
  2117. * be taken into account.
  2118. *
  2119. * @see avcodec_default_get_buffer()
  2120. *
  2121. * Video:
  2122. *
  2123. * If pic.reference is set then the frame will be read later by libavcodec.
  2124. * avcodec_align_dimensions2() should be used to find the required width and
  2125. * height, as they normally need to be rounded up to the next multiple of 16.
  2126. *
  2127. * If frame multithreading is used and thread_safe_callbacks is set,
  2128. * it may be called from a different thread, but not from more than one at
  2129. * once. Does not need to be reentrant.
  2130. *
  2131. * @see release_buffer(), reget_buffer()
  2132. * @see avcodec_align_dimensions2()
  2133. *
  2134. * Audio:
  2135. *
  2136. * Decoders request a buffer of a particular size by setting
  2137. * AVFrame.nb_samples prior to calling get_buffer(). The decoder may,
  2138. * however, utilize only part of the buffer by setting AVFrame.nb_samples
  2139. * to a smaller value in the output frame.
  2140. *
  2141. * Decoders cannot use the buffer after returning from
  2142. * avcodec_decode_audio4(), so they will not call release_buffer(), as it
  2143. * is assumed to be released immediately upon return.
  2144. *
  2145. * As a convenience, av_samples_get_buffer_size() and
  2146. * av_samples_fill_arrays() in libavutil may be used by custom get_buffer()
  2147. * functions to find the required data size and to fill data pointers and
  2148. * linesize. In AVFrame.linesize, only linesize[0] may be set for audio
  2149. * since all planes must be the same size.
  2150. *
  2151. * @see av_samples_get_buffer_size(), av_samples_fill_arrays()
  2152. *
  2153. * - encoding: unused
  2154. * - decoding: Set by libavcodec, user can override.
  2155. */
  2156. int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
  2157. /**
  2158. * Called to release buffers which were allocated with get_buffer.
  2159. * A released buffer can be reused in get_buffer().
  2160. * pic.data[*] must be set to NULL.
  2161. * May be called from a different thread if frame multithreading is used,
  2162. * but not by more than one thread at once, so does not need to be reentrant.
  2163. * - encoding: unused
  2164. * - decoding: Set by libavcodec, user can override.
  2165. */
  2166. void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
  2167. /**
  2168. * Called at the beginning of a frame to get cr buffer for it.
  2169. * Buffer type (size, hints) must be the same. libavcodec won't check it.
  2170. * libavcodec will pass previous buffer in pic, function should return
  2171. * same buffer or new buffer with old frame "painted" into it.
  2172. * If pic.data[0] == NULL must behave like get_buffer().
  2173. * if CODEC_CAP_DR1 is not set then reget_buffer() must call
  2174. * avcodec_default_reget_buffer() instead of providing buffers allocated by
  2175. * some other means.
  2176. * - encoding: unused
  2177. * - decoding: Set by libavcodec, user can override.
  2178. */
  2179. int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic);
  2180. /* - encoding parameters */
  2181. float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
  2182. float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
  2183. /**
  2184. * minimum quantizer
  2185. * - encoding: Set by user.
  2186. * - decoding: unused
  2187. */
  2188. int qmin;
  2189. /**
  2190. * maximum quantizer
  2191. * - encoding: Set by user.
  2192. * - decoding: unused
  2193. */
  2194. int qmax;
  2195. /**
  2196. * maximum quantizer difference between frames
  2197. * - encoding: Set by user.
  2198. * - decoding: unused
  2199. */
  2200. int max_qdiff;
  2201. /**
  2202. * ratecontrol qmin qmax limiting method
  2203. * 0-> clipping, 1-> use a nice continuous function to limit qscale wthin qmin/qmax.
  2204. * - encoding: Set by user.
  2205. * - decoding: unused
  2206. */
  2207. float rc_qsquish;
  2208. float rc_qmod_amp;
  2209. int rc_qmod_freq;
  2210. /**
  2211. * decoder bitstream buffer size
  2212. * - encoding: Set by user.
  2213. * - decoding: unused
  2214. */
  2215. int rc_buffer_size;
  2216. /**
  2217. * ratecontrol override, see RcOverride
  2218. * - encoding: Allocated/set/freed by user.
  2219. * - decoding: unused
  2220. */
  2221. int rc_override_count;
  2222. RcOverride *rc_override;
  2223. /**
  2224. * rate control equation
  2225. * - encoding: Set by user
  2226. * - decoding: unused
  2227. */
  2228. const char *rc_eq;
  2229. /**
  2230. * maximum bitrate
  2231. * - encoding: Set by user.
  2232. * - decoding: unused
  2233. */
  2234. int rc_max_rate;
  2235. /**
  2236. * minimum bitrate
  2237. * - encoding: Set by user.
  2238. * - decoding: unused
  2239. */
  2240. int rc_min_rate;
  2241. float rc_buffer_aggressivity;
  2242. /**
  2243. * initial complexity for pass1 ratecontrol
  2244. * - encoding: Set by user.
  2245. * - decoding: unused
  2246. */
  2247. float rc_initial_cplx;
  2248. /**
  2249. * Ratecontrol attempt to use, at maximum, <value> of what can be used without an underflow.
  2250. * - encoding: Set by user.
  2251. * - decoding: unused.
  2252. */
  2253. float rc_max_available_vbv_use;
  2254. /**
  2255. * Ratecontrol attempt to use, at least, <value> times the amount needed to prevent a vbv overflow.
  2256. * - encoding: Set by user.
  2257. * - decoding: unused.
  2258. */
  2259. float rc_min_vbv_overflow_use;
  2260. /**
  2261. * Number of bits which should be loaded into the rc buffer before decoding starts.
  2262. * - encoding: Set by user.
  2263. * - decoding: unused
  2264. */
  2265. int rc_initial_buffer_occupancy;
  2266. #define FF_CODER_TYPE_VLC 0
  2267. #define FF_CODER_TYPE_AC 1
  2268. #define FF_CODER_TYPE_RAW 2
  2269. #define FF_CODER_TYPE_RLE 3
  2270. #define FF_CODER_TYPE_DEFLATE 4
  2271. /**
  2272. * coder type
  2273. * - encoding: Set by user.
  2274. * - decoding: unused
  2275. */
  2276. int coder_type;
  2277. /**
  2278. * context model
  2279. * - encoding: Set by user.
  2280. * - decoding: unused
  2281. */
  2282. int context_model;
  2283. /**
  2284. * minimum Lagrange multipler
  2285. * - encoding: Set by user.
  2286. * - decoding: unused
  2287. */
  2288. int lmin;
  2289. /**
  2290. * maximum Lagrange multipler
  2291. * - encoding: Set by user.
  2292. * - decoding: unused
  2293. */
  2294. int lmax;
  2295. /**
  2296. * frame skip threshold
  2297. * - encoding: Set by user.
  2298. * - decoding: unused
  2299. */
  2300. int frame_skip_threshold;
  2301. /**
  2302. * frame skip factor
  2303. * - encoding: Set by user.
  2304. * - decoding: unused
  2305. */
  2306. int frame_skip_factor;
  2307. /**
  2308. * frame skip exponent
  2309. * - encoding: Set by user.
  2310. * - decoding: unused
  2311. */
  2312. int frame_skip_exp;
  2313. /**
  2314. * frame skip comparison function
  2315. * - encoding: Set by user.
  2316. * - decoding: unused
  2317. */
  2318. int frame_skip_cmp;
  2319. /**
  2320. * trellis RD quantization
  2321. * - encoding: Set by user.
  2322. * - decoding: unused
  2323. */
  2324. int trellis;
  2325. /**
  2326. * - encoding: Set by user.
  2327. * - decoding: unused
  2328. */
  2329. int min_prediction_order;
  2330. /**
  2331. * - encoding: Set by user.
  2332. * - decoding: unused
  2333. */
  2334. int max_prediction_order;
  2335. /**
  2336. * GOP timecode frame start number
  2337. * - encoding: Set by user, in non drop frame format
  2338. * - decoding: Set by libavcodec (timecode in the 25 bits format, -1 if unset)
  2339. */
  2340. int64_t timecode_frame_start;
  2341. /* The RTP callback: This function is called */
  2342. /* every time the encoder has a packet to send. */
  2343. /* It depends on the encoder if the data starts */
  2344. /* with a Start Code (it should). H.263 does. */
  2345. /* mb_nb contains the number of macroblocks */
  2346. /* encoded in the RTP payload. */
  2347. void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb);
  2348. int rtp_payload_size; /* The size of the RTP payload: the coder will */
  2349. /* do its best to deliver a chunk with size */
  2350. /* below rtp_payload_size, the chunk will start */
  2351. /* with a start code on some codecs like H.263. */
  2352. /* This doesn't take account of any particular */
  2353. /* headers inside the transmitted RTP payload. */
  2354. /* statistics, used for 2-pass encoding */
  2355. int mv_bits;
  2356. int header_bits;
  2357. int i_tex_bits;
  2358. int p_tex_bits;
  2359. int i_count;
  2360. int p_count;
  2361. int skip_count;
  2362. int misc_bits;
  2363. /**
  2364. * number of bits used for the previously encoded frame
  2365. * - encoding: Set by libavcodec.
  2366. * - decoding: unused
  2367. */
  2368. int frame_bits;
  2369. /**
  2370. * pass1 encoding statistics output buffer
  2371. * - encoding: Set by libavcodec.
  2372. * - decoding: unused
  2373. */
  2374. char *stats_out;
  2375. /**
  2376. * pass2 encoding statistics input buffer
  2377. * Concatenated stuff from stats_out of pass1 should be placed here.
  2378. * - encoding: Allocated/set/freed by user.
  2379. * - decoding: unused
  2380. */
  2381. char *stats_in;
  2382. /**
  2383. * Work around bugs in encoders which sometimes cannot be detected automatically.
  2384. * - encoding: Set by user
  2385. * - decoding: Set by user
  2386. */
  2387. int workaround_bugs;
  2388. #define FF_BUG_AUTODETECT 1 ///< autodetection
  2389. #define FF_BUG_OLD_MSMPEG4 2
  2390. #define FF_BUG_XVID_ILACE 4
  2391. #define FF_BUG_UMP4 8
  2392. #define FF_BUG_NO_PADDING 16
  2393. #define FF_BUG_AMV 32
  2394. #define FF_BUG_AC_VLC 0 ///< Will be removed, libavcodec can now handle these non-compliant files by default.
  2395. #define FF_BUG_QPEL_CHROMA 64
  2396. #define FF_BUG_STD_QPEL 128
  2397. #define FF_BUG_QPEL_CHROMA2 256
  2398. #define FF_BUG_DIRECT_BLOCKSIZE 512
  2399. #define FF_BUG_EDGE 1024
  2400. #define FF_BUG_HPEL_CHROMA 2048
  2401. #define FF_BUG_DC_CLIP 4096
  2402. #define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders.
  2403. #define FF_BUG_TRUNCATED 16384
  2404. /**
  2405. * strictly follow the standard (MPEG4, ...).
  2406. * - encoding: Set by user.
  2407. * - decoding: Set by user.
  2408. * Setting this to STRICT or higher means the encoder and decoder will
  2409. * generally do stupid things, whereas setting it to unofficial or lower
  2410. * will mean the encoder might produce output that is not supported by all
  2411. * spec-compliant decoders. Decoders don't differentiate between normal,
  2412. * unofficial and experimental (that is, they always try to decode things
  2413. * when they can) unless they are explicitly asked to behave stupidly
  2414. * (=strictly conform to the specs)
  2415. */
  2416. int strict_std_compliance;
  2417. #define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to an older more strict version of the spec or reference software.
  2418. #define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences.
  2419. #define FF_COMPLIANCE_NORMAL 0
  2420. #define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions
  2421. #define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things.
  2422. /**
  2423. * error concealment flags
  2424. * - encoding: unused
  2425. * - decoding: Set by user.
  2426. */
  2427. int error_concealment;
  2428. #define FF_EC_GUESS_MVS 1
  2429. #define FF_EC_DEBLOCK 2
  2430. /**
  2431. * debug
  2432. * - encoding: Set by user.
  2433. * - decoding: Set by user.
  2434. */
  2435. int debug;
  2436. #define FF_DEBUG_PICT_INFO 1
  2437. #define FF_DEBUG_RC 2
  2438. #define FF_DEBUG_BITSTREAM 4
  2439. #define FF_DEBUG_MB_TYPE 8
  2440. #define FF_DEBUG_QP 16
  2441. #define FF_DEBUG_MV 32
  2442. #define FF_DEBUG_DCT_COEFF 0x00000040
  2443. #define FF_DEBUG_SKIP 0x00000080
  2444. #define FF_DEBUG_STARTCODE 0x00000100
  2445. #define FF_DEBUG_PTS 0x00000200
  2446. #define FF_DEBUG_ER 0x00000400
  2447. #define FF_DEBUG_MMCO 0x00000800
  2448. #define FF_DEBUG_BUGS 0x00001000
  2449. #define FF_DEBUG_VIS_QP 0x00002000
  2450. #define FF_DEBUG_VIS_MB_TYPE 0x00004000
  2451. #define FF_DEBUG_BUFFERS 0x00008000
  2452. #define FF_DEBUG_THREADS 0x00010000
  2453. /**
  2454. * debug
  2455. * - encoding: Set by user.
  2456. * - decoding: Set by user.
  2457. */
  2458. int debug_mv;
  2459. #define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames
  2460. #define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames
  2461. #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames
  2462. /**
  2463. * Error recognition; may misdetect some more or less valid parts as errors.
  2464. * - encoding: unused
  2465. * - decoding: Set by user.
  2466. */
  2467. int err_recognition;
  2468. #define AV_EF_CRCCHECK (1<<0)
  2469. #define AV_EF_BITSTREAM (1<<1)
  2470. #define AV_EF_BUFFER (1<<2)
  2471. #define AV_EF_EXPLODE (1<<3)
  2472. #define AV_EF_CAREFUL (1<<16)
  2473. #define AV_EF_COMPLIANT (1<<17)
  2474. #define AV_EF_AGGRESSIVE (1<<18)
  2475. /**
  2476. * opaque 64bit number (generally a PTS) that will be reordered and
  2477. * output in AVFrame.reordered_opaque
  2478. * @deprecated in favor of pkt_pts
  2479. * - encoding: unused
  2480. * - decoding: Set by user.
  2481. */
  2482. int64_t reordered_opaque;
  2483. /**
  2484. * Hardware accelerator in use
  2485. * - encoding: unused.
  2486. * - decoding: Set by libavcodec
  2487. */
  2488. struct AVHWAccel *hwaccel;
  2489. /**
  2490. * Hardware accelerator context.
  2491. * For some hardware accelerators, a global context needs to be
  2492. * provided by the user. In that case, this holds display-dependent
  2493. * data FFmpeg cannot instantiate itself. Please refer to the
  2494. * FFmpeg HW accelerator documentation to know how to fill this
  2495. * is. e.g. for VA API, this is a struct vaapi_context.
  2496. * - encoding: unused
  2497. * - decoding: Set by user
  2498. */
  2499. void *hwaccel_context;
  2500. /**
  2501. * error
  2502. * - encoding: Set by libavcodec if flags&CODEC_FLAG_PSNR.
  2503. * - decoding: unused
  2504. */
  2505. uint64_t error[AV_NUM_DATA_POINTERS];
  2506. /**
  2507. * DCT algorithm, see FF_DCT_* below
  2508. * - encoding: Set by user.
  2509. * - decoding: unused
  2510. */
  2511. int dct_algo;
  2512. #define FF_DCT_AUTO 0
  2513. #define FF_DCT_FASTINT 1
  2514. #define FF_DCT_INT 2
  2515. #define FF_DCT_MMX 3
  2516. #define FF_DCT_ALTIVEC 5
  2517. #define FF_DCT_FAAN 6
  2518. /**
  2519. * IDCT algorithm, see FF_IDCT_* below.
  2520. * - encoding: Set by user.
  2521. * - decoding: Set by user.
  2522. */
  2523. int idct_algo;
  2524. #define FF_IDCT_AUTO 0
  2525. #define FF_IDCT_INT 1
  2526. #define FF_IDCT_SIMPLE 2
  2527. #define FF_IDCT_SIMPLEMMX 3
  2528. #define FF_IDCT_LIBMPEG2MMX 4
  2529. #define FF_IDCT_MMI 5
  2530. #define FF_IDCT_ARM 7
  2531. #define FF_IDCT_ALTIVEC 8
  2532. #define FF_IDCT_SH4 9
  2533. #define FF_IDCT_SIMPLEARM 10
  2534. #define FF_IDCT_H264 11
  2535. #define FF_IDCT_VP3 12
  2536. #define FF_IDCT_IPP 13
  2537. #define FF_IDCT_XVIDMMX 14
  2538. #define FF_IDCT_CAVS 15
  2539. #define FF_IDCT_SIMPLEARMV5TE 16
  2540. #define FF_IDCT_SIMPLEARMV6 17
  2541. #define FF_IDCT_SIMPLEVIS 18
  2542. #define FF_IDCT_WMV2 19
  2543. #define FF_IDCT_FAAN 20
  2544. #define FF_IDCT_EA 21
  2545. #define FF_IDCT_SIMPLENEON 22
  2546. #define FF_IDCT_SIMPLEALPHA 23
  2547. #define FF_IDCT_BINK 24
  2548. #if FF_API_DSP_MASK
  2549. /**
  2550. * Unused.
  2551. * @deprecated use av_set_cpu_flags_mask() instead.
  2552. */
  2553. attribute_deprecated unsigned dsp_mask;
  2554. #endif
  2555. /**
  2556. * bits per sample/pixel from the demuxer (needed for huffyuv).
  2557. * - encoding: Set by libavcodec.
  2558. * - decoding: Set by user.
  2559. */
  2560. int bits_per_coded_sample;
  2561. /**
  2562. * Bits per sample/pixel of internal libavcodec pixel/sample format.
  2563. * - encoding: set by user.
  2564. * - decoding: set by libavcodec.
  2565. */
  2566. int bits_per_raw_sample;
  2567. /**
  2568. * low resolution decoding, 1-> 1/2 size, 2->1/4 size
  2569. * - encoding: unused
  2570. * - decoding: Set by user.
  2571. */
  2572. int lowres;
  2573. /**
  2574. * the picture in the bitstream
  2575. * - encoding: Set by libavcodec.
  2576. * - decoding: Set by libavcodec.
  2577. */
  2578. AVFrame *coded_frame;
  2579. /**
  2580. * thread count
  2581. * is used to decide how many independent tasks should be passed to execute()
  2582. * - encoding: Set by user.
  2583. * - decoding: Set by user.
  2584. */
  2585. int thread_count;
  2586. /**
  2587. * Which multithreading methods to use.
  2588. * Use of FF_THREAD_FRAME will increase decoding delay by one frame per thread,
  2589. * so clients which cannot provide future frames should not use it.
  2590. *
  2591. * - encoding: Set by user, otherwise the default is used.
  2592. * - decoding: Set by user, otherwise the default is used.
  2593. */
  2594. int thread_type;
  2595. #define FF_THREAD_FRAME 1 ///< Decode more than one frame at once
  2596. #define FF_THREAD_SLICE 2 ///< Decode more than one part of a single frame at once
  2597. /**
  2598. * Which multithreading methods are in use by the codec.
  2599. * - encoding: Set by libavcodec.
  2600. * - decoding: Set by libavcodec.
  2601. */
  2602. int active_thread_type;
  2603. /**
  2604. * Set by the client if its custom get_buffer() callback can be called
  2605. * synchronously from another thread, which allows faster multithreaded decoding.
  2606. * draw_horiz_band() will be called from other threads regardless of this setting.
  2607. * Ignored if the default get_buffer() is used.
  2608. * - encoding: Set by user.
  2609. * - decoding: Set by user.
  2610. */
  2611. int thread_safe_callbacks;
  2612. /**
  2613. * The codec may call this to execute several independent things.
  2614. * It will return only after finishing all tasks.
  2615. * The user may replace this with some multithreaded implementation,
  2616. * the default implementation will execute the parts serially.
  2617. * @param count the number of things to execute
  2618. * - encoding: Set by libavcodec, user can override.
  2619. * - decoding: Set by libavcodec, user can override.
  2620. */
  2621. int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size);
  2622. /**
  2623. * The codec may call this to execute several independent things.
  2624. * It will return only after finishing all tasks.
  2625. * The user may replace this with some multithreaded implementation,
  2626. * the default implementation will execute the parts serially.
  2627. * Also see avcodec_thread_init and e.g. the --enable-pthread configure option.
  2628. * @param c context passed also to func
  2629. * @param count the number of things to execute
  2630. * @param arg2 argument passed unchanged to func
  2631. * @param ret return values of executed functions, must have space for "count" values. May be NULL.
  2632. * @param func function that will be called count times, with jobnr from 0 to count-1.
  2633. * threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no
  2634. * two instances of func executing at the same time will have the same threadnr.
  2635. * @return always 0 currently, but code should handle a future improvement where when any call to func
  2636. * returns < 0 no further calls to func may be done and < 0 is returned.
  2637. * - encoding: Set by libavcodec, user can override.
  2638. * - decoding: Set by libavcodec, user can override.
  2639. */
  2640. int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count);
  2641. /**
  2642. * thread opaque
  2643. * Can be used by execute() to store some per AVCodecContext stuff.
  2644. * - encoding: set by execute()
  2645. * - decoding: set by execute()
  2646. */
  2647. void *thread_opaque;
  2648. /**
  2649. * noise vs. sse weight for the nsse comparsion function
  2650. * - encoding: Set by user.
  2651. * - decoding: unused
  2652. */
  2653. int nsse_weight;
  2654. /**
  2655. * profile
  2656. * - encoding: Set by user.
  2657. * - decoding: Set by libavcodec.
  2658. */
  2659. int profile;
  2660. #define FF_PROFILE_UNKNOWN -99
  2661. #define FF_PROFILE_RESERVED -100
  2662. #define FF_PROFILE_AAC_MAIN 0
  2663. #define FF_PROFILE_AAC_LOW 1
  2664. #define FF_PROFILE_AAC_SSR 2
  2665. #define FF_PROFILE_AAC_LTP 3
  2666. #define FF_PROFILE_AAC_HE 4
  2667. #define FF_PROFILE_AAC_HE_V2 28
  2668. #define FF_PROFILE_AAC_LD 22
  2669. #define FF_PROFILE_AAC_ELD 38
  2670. #define FF_PROFILE_DTS 20
  2671. #define FF_PROFILE_DTS_ES 30
  2672. #define FF_PROFILE_DTS_96_24 40
  2673. #define FF_PROFILE_DTS_HD_HRA 50
  2674. #define FF_PROFILE_DTS_HD_MA 60
  2675. #define FF_PROFILE_MPEG2_422 0
  2676. #define FF_PROFILE_MPEG2_HIGH 1
  2677. #define FF_PROFILE_MPEG2_SS 2
  2678. #define FF_PROFILE_MPEG2_SNR_SCALABLE 3
  2679. #define FF_PROFILE_MPEG2_MAIN 4
  2680. #define FF_PROFILE_MPEG2_SIMPLE 5
  2681. #define FF_PROFILE_H264_CONSTRAINED (1<<9) // 8+1; constraint_set1_flag
  2682. #define FF_PROFILE_H264_INTRA (1<<11) // 8+3; constraint_set3_flag
  2683. #define FF_PROFILE_H264_BASELINE 66
  2684. #define FF_PROFILE_H264_CONSTRAINED_BASELINE (66|FF_PROFILE_H264_CONSTRAINED)
  2685. #define FF_PROFILE_H264_MAIN 77
  2686. #define FF_PROFILE_H264_EXTENDED 88
  2687. #define FF_PROFILE_H264_HIGH 100
  2688. #define FF_PROFILE_H264_HIGH_10 110
  2689. #define FF_PROFILE_H264_HIGH_10_INTRA (110|FF_PROFILE_H264_INTRA)
  2690. #define FF_PROFILE_H264_HIGH_422 122
  2691. #define FF_PROFILE_H264_HIGH_422_INTRA (122|FF_PROFILE_H264_INTRA)
  2692. #define FF_PROFILE_H264_HIGH_444 144
  2693. #define FF_PROFILE_H264_HIGH_444_PREDICTIVE 244
  2694. #define FF_PROFILE_H264_HIGH_444_INTRA (244|FF_PROFILE_H264_INTRA)
  2695. #define FF_PROFILE_H264_CAVLC_444 44
  2696. #define FF_PROFILE_VC1_SIMPLE 0
  2697. #define FF_PROFILE_VC1_MAIN 1
  2698. #define FF_PROFILE_VC1_COMPLEX 2
  2699. #define FF_PROFILE_VC1_ADVANCED 3
  2700. #define FF_PROFILE_MPEG4_SIMPLE 0
  2701. #define FF_PROFILE_MPEG4_SIMPLE_SCALABLE 1
  2702. #define FF_PROFILE_MPEG4_CORE 2
  2703. #define FF_PROFILE_MPEG4_MAIN 3
  2704. #define FF_PROFILE_MPEG4_N_BIT 4
  2705. #define FF_PROFILE_MPEG4_SCALABLE_TEXTURE 5
  2706. #define FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION 6
  2707. #define FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE 7
  2708. #define FF_PROFILE_MPEG4_HYBRID 8
  2709. #define FF_PROFILE_MPEG4_ADVANCED_REAL_TIME 9
  2710. #define FF_PROFILE_MPEG4_CORE_SCALABLE 10
  2711. #define FF_PROFILE_MPEG4_ADVANCED_CODING 11
  2712. #define FF_PROFILE_MPEG4_ADVANCED_CORE 12
  2713. #define FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE 13
  2714. #define FF_PROFILE_MPEG4_SIMPLE_STUDIO 14
  2715. #define FF_PROFILE_MPEG4_ADVANCED_SIMPLE 15
  2716. /**
  2717. * level
  2718. * - encoding: Set by user.
  2719. * - decoding: Set by libavcodec.
  2720. */
  2721. int level;
  2722. #define FF_LEVEL_UNKNOWN -99
  2723. /**
  2724. *
  2725. * - encoding: unused
  2726. * - decoding: Set by user.
  2727. */
  2728. enum AVDiscard skip_loop_filter;
  2729. /**
  2730. *
  2731. * - encoding: unused
  2732. * - decoding: Set by user.
  2733. */
  2734. enum AVDiscard skip_idct;
  2735. /**
  2736. *
  2737. * - encoding: unused
  2738. * - decoding: Set by user.
  2739. */
  2740. enum AVDiscard skip_frame;
  2741. /**
  2742. * Header containing style information for text subtitles.
  2743. * For SUBTITLE_ASS subtitle type, it should contain the whole ASS
  2744. * [Script Info] and [V4+ Styles] section, plus the [Events] line and
  2745. * the Format line following. It shouldn't include any Dialogue line.
  2746. * - encoding: Set/allocated/freed by user (before avcodec_open2())
  2747. * - decoding: Set/allocated/freed by libavcodec (by avcodec_open2())
  2748. */
  2749. uint8_t *subtitle_header;
  2750. int subtitle_header_size;
  2751. /**
  2752. * Simulates errors in the bitstream to test error concealment.
  2753. * - encoding: Set by user.
  2754. * - decoding: unused
  2755. */
  2756. int error_rate;
  2757. /**
  2758. * Current packet as passed into the decoder, to avoid having
  2759. * to pass the packet into every function. Currently only valid
  2760. * inside lavc and get/release_buffer callbacks.
  2761. * - decoding: set by avcodec_decode_*, read by get_buffer() for setting pkt_pts
  2762. * - encoding: unused
  2763. */
  2764. AVPacket *pkt;
  2765. /**
  2766. * VBV delay coded in the last frame (in periods of a 27 MHz clock).
  2767. * Used for compliant TS muxing.
  2768. * - encoding: Set by libavcodec.
  2769. * - decoding: unused.
  2770. */
  2771. uint64_t vbv_delay;
  2772. /**
  2773. * Timebase in which pkt_dts/pts and AVPacket.dts/pts are.
  2774. * Code outside libavcodec should access this field using:
  2775. * avcodec_set_pkt_timebase(avctx)
  2776. * - encoding unused.
  2777. * - decodimg set by user
  2778. */
  2779. AVRational pkt_timebase;
  2780. /**
  2781. * AVCodecDescriptor
  2782. * Code outside libavcodec should access this field using:
  2783. * avcodec_get_codec_descriptior(avctx)
  2784. * - encoding: unused.
  2785. * - decoding: set by libavcodec.
  2786. */
  2787. const AVCodecDescriptor *codec_descriptor;
  2788. /**
  2789. * Current statistics for PTS correction.
  2790. * - decoding: maintained and used by libavcodec, not intended to be used by user apps
  2791. * - encoding: unused
  2792. */
  2793. int64_t pts_correction_num_faulty_pts; /// Number of incorrect PTS values so far
  2794. int64_t pts_correction_num_faulty_dts; /// Number of incorrect DTS values so far
  2795. int64_t pts_correction_last_pts; /// PTS of the last frame
  2796. int64_t pts_correction_last_dts; /// DTS of the last frame
  2797. } AVCodecContext;
  2798. AVRational av_codec_get_pkt_timebase (const AVCodecContext *avctx);
  2799. void av_codec_set_pkt_timebase (AVCodecContext *avctx, AVRational val);
  2800. const AVCodecDescriptor *av_codec_get_codec_descriptor(const AVCodecContext *avctx);
  2801. void av_codec_set_codec_descriptor(AVCodecContext *avctx, const AVCodecDescriptor *desc);
  2802. /**
  2803. * AVProfile.
  2804. */
  2805. typedef struct AVProfile {
  2806. int profile;
  2807. const char *name; ///< short name for the profile
  2808. } AVProfile;
  2809. typedef struct AVCodecDefault AVCodecDefault;
  2810. struct AVSubtitle;
  2811. /**
  2812. * AVCodec.
  2813. */
  2814. typedef struct AVCodec {
  2815. /**
  2816. * Name of the codec implementation.
  2817. * The name is globally unique among encoders and among decoders (but an
  2818. * encoder and a decoder can share the same name).
  2819. * This is the primary way to find a codec from the user perspective.
  2820. */
  2821. const char *name;
  2822. /**
  2823. * Descriptive name for the codec, meant to be more human readable than name.
  2824. * You should use the NULL_IF_CONFIG_SMALL() macro to define it.
  2825. */
  2826. const char *long_name;
  2827. enum AVMediaType type;
  2828. enum AVCodecID id;
  2829. /**
  2830. * Codec capabilities.
  2831. * see CODEC_CAP_*
  2832. */
  2833. int capabilities;
  2834. const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0}
  2835. const enum PixelFormat *pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1
  2836. const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0
  2837. const enum AVSampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1
  2838. const uint64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0
  2839. uint8_t max_lowres; ///< maximum value for lowres supported by the decoder
  2840. const AVClass *priv_class; ///< AVClass for the private context
  2841. const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
  2842. /*****************************************************************
  2843. * No fields below this line are part of the public API. They
  2844. * may not be used outside of libavcodec and can be changed and
  2845. * removed at will.
  2846. * New public fields should be added right above.
  2847. *****************************************************************
  2848. */
  2849. int priv_data_size;
  2850. struct AVCodec *next;
  2851. /**
  2852. * @name Frame-level threading support functions
  2853. * @{
  2854. */
  2855. /**
  2856. * If defined, called on thread contexts when they are created.
  2857. * If the codec allocates writable tables in init(), re-allocate them here.
  2858. * priv_data will be set to a copy of the original.
  2859. */
  2860. int (*init_thread_copy)(AVCodecContext *);
  2861. /**
  2862. * Copy necessary context variables from a previous thread context to the current one.
  2863. * If not defined, the next thread will start automatically; otherwise, the codec
  2864. * must call ff_thread_finish_setup().
  2865. *
  2866. * dst and src will (rarely) point to the same context, in which case memcpy should be skipped.
  2867. */
  2868. int (*update_thread_context)(AVCodecContext *dst, const AVCodecContext *src);
  2869. /** @} */
  2870. /**
  2871. * Private codec-specific defaults.
  2872. */
  2873. const AVCodecDefault *defaults;
  2874. /**
  2875. * Initialize codec static data, called from avcodec_register().
  2876. */
  2877. void (*init_static_data)(struct AVCodec *codec);
  2878. int (*init)(AVCodecContext *);
  2879. int (*encode_sub)(AVCodecContext *, uint8_t *buf, int buf_size,
  2880. const struct AVSubtitle *sub);
  2881. /**
  2882. * Encode data to an AVPacket.
  2883. *
  2884. * @param avctx codec context
  2885. * @param avpkt output AVPacket (may contain a user-provided buffer)
  2886. * @param[in] frame AVFrame containing the raw data to be encoded
  2887. * @param[out] got_packet_ptr encoder sets to 0 or 1 to indicate that a
  2888. * non-empty packet was returned in avpkt.
  2889. * @return 0 on success, negative error code on failure
  2890. */
  2891. int (*encode2)(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame,
  2892. int *got_packet_ptr);
  2893. int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt);
  2894. int (*close)(AVCodecContext *);
  2895. /**
  2896. * Flush buffers.
  2897. * Will be called when seeking
  2898. */
  2899. void (*flush)(AVCodecContext *);
  2900. } AVCodec;
  2901. /**
  2902. * AVHWAccel.
  2903. */
  2904. typedef struct AVHWAccel {
  2905. /**
  2906. * Name of the hardware accelerated codec.
  2907. * The name is globally unique among encoders and among decoders (but an
  2908. * encoder and a decoder can share the same name).
  2909. */
  2910. const char *name;
  2911. /**
  2912. * Type of codec implemented by the hardware accelerator.
  2913. *
  2914. * See AVMEDIA_TYPE_xxx
  2915. */
  2916. enum AVMediaType type;
  2917. /**
  2918. * Codec implemented by the hardware accelerator.
  2919. *
  2920. * See AV_CODEC_ID_xxx
  2921. */
  2922. enum AVCodecID id;
  2923. /**
  2924. * Supported pixel format.
  2925. *
  2926. * Only hardware accelerated formats are supported here.
  2927. */
  2928. enum PixelFormat pix_fmt;
  2929. /**
  2930. * Hardware accelerated codec capabilities.
  2931. * see FF_HWACCEL_CODEC_CAP_*
  2932. */
  2933. int capabilities;
  2934. struct AVHWAccel *next;
  2935. /**
  2936. * Called at the beginning of each frame or field picture.
  2937. *
  2938. * Meaningful frame information (codec specific) is guaranteed to
  2939. * be parsed at this point. This function is mandatory.
  2940. *
  2941. * Note that buf can be NULL along with buf_size set to 0.
  2942. * Otherwise, this means the whole frame is available at this point.
  2943. *
  2944. * @param avctx the codec context
  2945. * @param buf the frame data buffer base
  2946. * @param buf_size the size of the frame in bytes
  2947. * @return zero if successful, a negative value otherwise
  2948. */
  2949. int (*start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
  2950. /**
  2951. * Callback for each slice.
  2952. *
  2953. * Meaningful slice information (codec specific) is guaranteed to
  2954. * be parsed at this point. This function is mandatory.
  2955. *
  2956. * @param avctx the codec context
  2957. * @param buf the slice data buffer base
  2958. * @param buf_size the size of the slice in bytes
  2959. * @return zero if successful, a negative value otherwise
  2960. */
  2961. int (*decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
  2962. /**
  2963. * Called at the end of each frame or field picture.
  2964. *
  2965. * The whole picture is parsed at this point and can now be sent
  2966. * to the hardware accelerator. This function is mandatory.
  2967. *
  2968. * @param avctx the codec context
  2969. * @return zero if successful, a negative value otherwise
  2970. */
  2971. int (*end_frame)(AVCodecContext *avctx);
  2972. /**
  2973. * Size of HW accelerator private data.
  2974. *
  2975. * Private data is allocated with av_mallocz() before
  2976. * AVCodecContext.get_buffer() and deallocated after
  2977. * AVCodecContext.release_buffer().
  2978. */
  2979. int priv_data_size;
  2980. } AVHWAccel;
  2981. /**
  2982. * @defgroup lavc_picture AVPicture
  2983. *
  2984. * Functions for working with AVPicture
  2985. * @{
  2986. */
  2987. /**
  2988. * four components are given, that's all.
  2989. * the last component is alpha
  2990. */
  2991. typedef struct AVPicture {
  2992. uint8_t *data[AV_NUM_DATA_POINTERS];
  2993. int linesize[AV_NUM_DATA_POINTERS]; ///< number of bytes per line
  2994. } AVPicture;
  2995. /**
  2996. * @}
  2997. */
  2998. enum AVSubtitleType {
  2999. SUBTITLE_NONE,
  3000. SUBTITLE_BITMAP, ///< A bitmap, pict will be set
  3001. /**
  3002. * Plain text, the text field must be set by the decoder and is
  3003. * authoritative. ass and pict fields may contain approximations.
  3004. */
  3005. SUBTITLE_TEXT,
  3006. /**
  3007. * Formatted text, the ass field must be set by the decoder and is
  3008. * authoritative. pict and text fields may contain approximations.
  3009. */
  3010. SUBTITLE_ASS,
  3011. };
  3012. typedef struct AVSubtitleRect {
  3013. int x; ///< top left corner of pict, undefined when pict is not set
  3014. int y; ///< top left corner of pict, undefined when pict is not set
  3015. int w; ///< width of pict, undefined when pict is not set
  3016. int h; ///< height of pict, undefined when pict is not set
  3017. int nb_colors; ///< number of colors in pict, undefined when pict is not set
  3018. /**
  3019. * data+linesize for the bitmap of this subtitle.
  3020. * can be set for text/ass as well once they where rendered
  3021. */
  3022. AVPicture pict;
  3023. enum AVSubtitleType type;
  3024. char *text; ///< 0 terminated plain UTF-8 text
  3025. /**
  3026. * 0 terminated ASS/SSA compatible event line.
  3027. * The presentation of this is unaffected by the other values in this
  3028. * struct.
  3029. */
  3030. char *ass;
  3031. /**
  3032. * 1 indicates this subtitle is a forced subtitle.
  3033. * A forced subtitle should be displayed even when subtitles are hidden.
  3034. */
  3035. int forced;
  3036. } AVSubtitleRect;
  3037. typedef struct AVSubtitle {
  3038. uint16_t format; /* 0 = graphics */
  3039. uint32_t start_display_time; /* relative to packet pts, in ms */
  3040. uint32_t end_display_time; /* relative to packet pts, in ms */
  3041. unsigned num_rects;
  3042. AVSubtitleRect **rects;
  3043. int64_t pts; ///< Same as packet pts, in AV_TIME_BASE
  3044. } AVSubtitle;
  3045. /**
  3046. * If c is NULL, returns the first registered codec,
  3047. * if c is non-NULL, returns the next registered codec after c,
  3048. * or NULL if c is the last one.
  3049. */
  3050. AVCodec *av_codec_next(const AVCodec *c);
  3051. /**
  3052. * Return the LIBAVCODEC_VERSION_INT constant.
  3053. */
  3054. unsigned avcodec_version(void);
  3055. /**
  3056. * Return the libavcodec build-time configuration.
  3057. */
  3058. const char *avcodec_configuration(void);
  3059. /**
  3060. * Return the libavcodec license.
  3061. */
  3062. const char *avcodec_license(void);
  3063. /**
  3064. * Register the codec codec and initialize libavcodec.
  3065. *
  3066. * @warning either this function or avcodec_register_all() must be called
  3067. * before any other libavcodec functions.
  3068. *
  3069. * @see avcodec_register_all()
  3070. */
  3071. void avcodec_register(AVCodec *codec);
  3072. /**
  3073. * Register all the codecs, parsers and bitstream filters which were enabled at
  3074. * configuration time. If you do not call this function you can select exactly
  3075. * which formats you want to support, by using the individual registration
  3076. * functions.
  3077. *
  3078. * @see avcodec_register
  3079. * @see av_register_codec_parser
  3080. * @see av_register_bitstream_filter
  3081. */
  3082. void avcodec_register_all(void);
  3083. #if FF_API_ALLOC_CONTEXT
  3084. /**
  3085. * Allocate an AVCodecContext and set its fields to default values. The
  3086. * resulting struct can be deallocated by simply calling av_free().
  3087. *
  3088. * @return An AVCodecContext filled with default values or NULL on failure.
  3089. * @see avcodec_get_context_defaults
  3090. *
  3091. * @deprecated use avcodec_alloc_context3()
  3092. */
  3093. attribute_deprecated
  3094. AVCodecContext *avcodec_alloc_context(void);
  3095. /** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
  3096. * we WILL change its arguments and name a few times! */
  3097. attribute_deprecated
  3098. AVCodecContext *avcodec_alloc_context2(enum AVMediaType);
  3099. /**
  3100. * Set the fields of the given AVCodecContext to default values.
  3101. *
  3102. * @param s The AVCodecContext of which the fields should be set to default values.
  3103. * @deprecated use avcodec_get_context_defaults3
  3104. */
  3105. attribute_deprecated
  3106. void avcodec_get_context_defaults(AVCodecContext *s);
  3107. /** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
  3108. * we WILL change its arguments and name a few times! */
  3109. attribute_deprecated
  3110. void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType);
  3111. #endif
  3112. /**
  3113. * Allocate an AVCodecContext and set its fields to default values. The
  3114. * resulting struct can be deallocated by calling avcodec_close() on it followed
  3115. * by av_free().
  3116. *
  3117. * @param codec if non-NULL, allocate private data and initialize defaults
  3118. * for the given codec. It is illegal to then call avcodec_open2()
  3119. * with a different codec.
  3120. * If NULL, then the codec-specific defaults won't be initialized,
  3121. * which may result in suboptimal default settings (this is
  3122. * important mainly for encoders, e.g. libx264).
  3123. *
  3124. * @return An AVCodecContext filled with default values or NULL on failure.
  3125. * @see avcodec_get_context_defaults
  3126. */
  3127. AVCodecContext *avcodec_alloc_context3(const AVCodec *codec);
  3128. /**
  3129. * Set the fields of the given AVCodecContext to default values corresponding
  3130. * to the given codec (defaults may be codec-dependent).
  3131. *
  3132. * Do not call this function if a non-NULL codec has been passed
  3133. * to avcodec_alloc_context3() that allocated this AVCodecContext.
  3134. * If codec is non-NULL, it is illegal to call avcodec_open2() with a
  3135. * different codec on this AVCodecContext.
  3136. */
  3137. int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec);
  3138. /**
  3139. * Get the AVClass for AVCodecContext. It can be used in combination with
  3140. * AV_OPT_SEARCH_FAKE_OBJ for examining options.
  3141. *
  3142. * @see av_opt_find().
  3143. */
  3144. const AVClass *avcodec_get_class(void);
  3145. /**
  3146. * Get the AVClass for AVFrame. It can be used in combination with
  3147. * AV_OPT_SEARCH_FAKE_OBJ for examining options.
  3148. *
  3149. * @see av_opt_find().
  3150. */
  3151. const AVClass *avcodec_get_frame_class(void);
  3152. /**
  3153. * Get the AVClass for AVSubtitleRect. It can be used in combination with
  3154. * AV_OPT_SEARCH_FAKE_OBJ for examining options.
  3155. *
  3156. * @see av_opt_find().
  3157. */
  3158. const AVClass *avcodec_get_subtitle_rect_class(void);
  3159. /**
  3160. * Copy the settings of the source AVCodecContext into the destination
  3161. * AVCodecContext. The resulting destination codec context will be
  3162. * unopened, i.e. you are required to call avcodec_open2() before you
  3163. * can use this AVCodecContext to decode/encode video/audio data.
  3164. *
  3165. * @param dest target codec context, should be initialized with
  3166. * avcodec_alloc_context3(), but otherwise uninitialized
  3167. * @param src source codec context
  3168. * @return AVERROR() on error (e.g. memory allocation error), 0 on success
  3169. */
  3170. int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src);
  3171. /**
  3172. * Allocate an AVFrame and set its fields to default values. The resulting
  3173. * struct must be freed using avcodec_free_frame().
  3174. *
  3175. * @return An AVFrame filled with default values or NULL on failure.
  3176. * @see avcodec_get_frame_defaults
  3177. */
  3178. AVFrame *avcodec_alloc_frame(void);
  3179. /**
  3180. * Set the fields of the given AVFrame to default values.
  3181. *
  3182. * @param frame The AVFrame of which the fields should be set to default values.
  3183. */
  3184. void avcodec_get_frame_defaults(AVFrame *frame);
  3185. /**
  3186. * Free the frame and any dynamically allocated objects in it,
  3187. * e.g. extended_data.
  3188. *
  3189. * @param frame frame to be freed. The pointer will be set to NULL.
  3190. *
  3191. * @warning this function does NOT free the data buffers themselves
  3192. * (it does not know how, since they might have been allocated with
  3193. * a custom get_buffer()).
  3194. */
  3195. void avcodec_free_frame(AVFrame **frame);
  3196. #if FF_API_AVCODEC_OPEN
  3197. /**
  3198. * Initialize the AVCodecContext to use the given AVCodec. Prior to using this
  3199. * function the context has to be allocated.
  3200. *
  3201. * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
  3202. * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
  3203. * retrieving a codec.
  3204. *
  3205. * @warning This function is not thread safe!
  3206. *
  3207. * @code
  3208. * avcodec_register_all();
  3209. * codec = avcodec_find_decoder(AV_CODEC_ID_H264);
  3210. * if (!codec)
  3211. * exit(1);
  3212. *
  3213. * context = avcodec_alloc_context3(codec);
  3214. *
  3215. * if (avcodec_open(context, codec) < 0)
  3216. * exit(1);
  3217. * @endcode
  3218. *
  3219. * @param avctx The context which will be set up to use the given codec.
  3220. * @param codec The codec to use within the context.
  3221. * @return zero on success, a negative value on error
  3222. * @see avcodec_alloc_context3, avcodec_find_decoder, avcodec_find_encoder, avcodec_close
  3223. *
  3224. * @deprecated use avcodec_open2
  3225. */
  3226. attribute_deprecated
  3227. int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
  3228. #endif
  3229. /**
  3230. * Initialize the AVCodecContext to use the given AVCodec. Prior to using this
  3231. * function the context has to be allocated with avcodec_alloc_context3().
  3232. *
  3233. * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
  3234. * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
  3235. * retrieving a codec.
  3236. *
  3237. * @warning This function is not thread safe!
  3238. *
  3239. * @code
  3240. * avcodec_register_all();
  3241. * av_dict_set(&opts, "b", "2.5M", 0);
  3242. * codec = avcodec_find_decoder(AV_CODEC_ID_H264);
  3243. * if (!codec)
  3244. * exit(1);
  3245. *
  3246. * context = avcodec_alloc_context3(codec);
  3247. *
  3248. * if (avcodec_open2(context, codec, opts) < 0)
  3249. * exit(1);
  3250. * @endcode
  3251. *
  3252. * @param avctx The context to initialize.
  3253. * @param codec The codec to open this context for. If a non-NULL codec has been
  3254. * previously passed to avcodec_alloc_context3() or
  3255. * avcodec_get_context_defaults3() for this context, then this
  3256. * parameter MUST be either NULL or equal to the previously passed
  3257. * codec.
  3258. * @param options A dictionary filled with AVCodecContext and codec-private options.
  3259. * On return this object will be filled with options that were not found.
  3260. *
  3261. * @return zero on success, a negative value on error
  3262. * @see avcodec_alloc_context3(), avcodec_find_decoder(), avcodec_find_encoder(),
  3263. * av_dict_set(), av_opt_find().
  3264. */
  3265. int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options);
  3266. /**
  3267. * Close a given AVCodecContext and free all the data associated with it
  3268. * (but not the AVCodecContext itself).
  3269. *
  3270. * Calling this function on an AVCodecContext that hasn't been opened will free
  3271. * the codec-specific data allocated in avcodec_alloc_context3() /
  3272. * avcodec_get_context_defaults3() with a non-NULL codec. Subsequent calls will
  3273. * do nothing.
  3274. */
  3275. int avcodec_close(AVCodecContext *avctx);
  3276. /**
  3277. * Free all allocated data in the given subtitle struct.
  3278. *
  3279. * @param sub AVSubtitle to free.
  3280. */
  3281. void avsubtitle_free(AVSubtitle *sub);
  3282. /**
  3283. * @}
  3284. */
  3285. /**
  3286. * @addtogroup lavc_packet
  3287. * @{
  3288. */
  3289. /**
  3290. * Default packet destructor.
  3291. */
  3292. void av_destruct_packet(AVPacket *pkt);
  3293. /**
  3294. * Initialize optional fields of a packet with default values.
  3295. *
  3296. * Note, this does not touch the data and size members, which have to be
  3297. * initialized separately.
  3298. *
  3299. * @param pkt packet
  3300. */
  3301. void av_init_packet(AVPacket *pkt);
  3302. /**
  3303. * Allocate the payload of a packet and initialize its fields with
  3304. * default values.
  3305. *
  3306. * @param pkt packet
  3307. * @param size wanted payload size
  3308. * @return 0 if OK, AVERROR_xxx otherwise
  3309. */
  3310. int av_new_packet(AVPacket *pkt, int size);
  3311. /**
  3312. * Reduce packet size, correctly zeroing padding
  3313. *
  3314. * @param pkt packet
  3315. * @param size new size
  3316. */
  3317. void av_shrink_packet(AVPacket *pkt, int size);
  3318. /**
  3319. * Increase packet size, correctly zeroing padding
  3320. *
  3321. * @param pkt packet
  3322. * @param grow_by number of bytes by which to increase the size of the packet
  3323. */
  3324. int av_grow_packet(AVPacket *pkt, int grow_by);
  3325. /**
  3326. * @warning This is a hack - the packet memory allocation stuff is broken. The
  3327. * packet is allocated if it was not really allocated.
  3328. */
  3329. int av_dup_packet(AVPacket *pkt);
  3330. /**
  3331. * Copy packet, including contents
  3332. *
  3333. * @return 0 on success, negative AVERROR on fail
  3334. */
  3335. int av_copy_packet(AVPacket *dst, AVPacket *src);
  3336. /**
  3337. * Free a packet.
  3338. *
  3339. * @param pkt packet to free
  3340. */
  3341. void av_free_packet(AVPacket *pkt);
  3342. /**
  3343. * Allocate new information of a packet.
  3344. *
  3345. * @param pkt packet
  3346. * @param type side information type
  3347. * @param size side information size
  3348. * @return pointer to fresh allocated data or NULL otherwise
  3349. */
  3350. uint8_t* av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
  3351. int size);
  3352. /**
  3353. * Shrink the already allocated side data buffer
  3354. *
  3355. * @param pkt packet
  3356. * @param type side information type
  3357. * @param size new side information size
  3358. * @return 0 on success, < 0 on failure
  3359. */
  3360. int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
  3361. int size);
  3362. /**
  3363. * Get side information from packet.
  3364. *
  3365. * @param pkt packet
  3366. * @param type desired side information type
  3367. * @param size pointer for side information size to store (optional)
  3368. * @return pointer to data if present or NULL otherwise
  3369. */
  3370. uint8_t* av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
  3371. int *size);
  3372. int av_packet_merge_side_data(AVPacket *pkt);
  3373. int av_packet_split_side_data(AVPacket *pkt);
  3374. /**
  3375. * @}
  3376. */
  3377. /**
  3378. * @addtogroup lavc_decoding
  3379. * @{
  3380. */
  3381. /**
  3382. * Find a registered decoder with a matching codec ID.
  3383. *
  3384. * @param id AVCodecID of the requested decoder
  3385. * @return A decoder if one was found, NULL otherwise.
  3386. */
  3387. AVCodec *avcodec_find_decoder(enum AVCodecID id);
  3388. /**
  3389. * Find a registered decoder with the specified name.
  3390. *
  3391. * @param name name of the requested decoder
  3392. * @return A decoder if one was found, NULL otherwise.
  3393. */
  3394. AVCodec *avcodec_find_decoder_by_name(const char *name);
  3395. int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
  3396. void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
  3397. int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic);
  3398. /**
  3399. * Return the amount of padding in pixels which the get_buffer callback must
  3400. * provide around the edge of the image for codecs which do not have the
  3401. * CODEC_FLAG_EMU_EDGE flag.
  3402. *
  3403. * @return Required padding in pixels.
  3404. */
  3405. unsigned avcodec_get_edge_width(void);
  3406. /**
  3407. * Modify width and height values so that they will result in a memory
  3408. * buffer that is acceptable for the codec if you do not use any horizontal
  3409. * padding.
  3410. *
  3411. * May only be used if a codec with CODEC_CAP_DR1 has been opened.
  3412. * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased
  3413. * according to avcodec_get_edge_width() before.
  3414. */
  3415. void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
  3416. /**
  3417. * Modify width and height values so that they will result in a memory
  3418. * buffer that is acceptable for the codec if you also ensure that all
  3419. * line sizes are a multiple of the respective linesize_align[i].
  3420. *
  3421. * May only be used if a codec with CODEC_CAP_DR1 has been opened.
  3422. * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased
  3423. * according to avcodec_get_edge_width() before.
  3424. */
  3425. void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
  3426. int linesize_align[AV_NUM_DATA_POINTERS]);
  3427. #if FF_API_OLD_DECODE_AUDIO
  3428. /**
  3429. * Wrapper function which calls avcodec_decode_audio4.
  3430. *
  3431. * @deprecated Use avcodec_decode_audio4 instead.
  3432. *
  3433. * Decode the audio frame of size avpkt->size from avpkt->data into samples.
  3434. * Some decoders may support multiple frames in a single AVPacket, such
  3435. * decoders would then just decode the first frame. In this case,
  3436. * avcodec_decode_audio3 has to be called again with an AVPacket that contains
  3437. * the remaining data in order to decode the second frame etc.
  3438. * If no frame
  3439. * could be outputted, frame_size_ptr is zero. Otherwise, it is the
  3440. * decompressed frame size in bytes.
  3441. *
  3442. * @warning You must set frame_size_ptr to the allocated size of the
  3443. * output buffer before calling avcodec_decode_audio3().
  3444. *
  3445. * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than
  3446. * the actual read bytes because some optimized bitstream readers read 32 or 64
  3447. * bits at once and could read over the end.
  3448. *
  3449. * @warning The end of the input buffer avpkt->data should be set to 0 to ensure that
  3450. * no overreading happens for damaged MPEG streams.
  3451. *
  3452. * @warning You must not provide a custom get_buffer() when using
  3453. * avcodec_decode_audio3(). Doing so will override it with
  3454. * avcodec_default_get_buffer. Use avcodec_decode_audio4() instead,
  3455. * which does allow the application to provide a custom get_buffer().
  3456. *
  3457. * @note You might have to align the input buffer avpkt->data and output buffer
  3458. * samples. The alignment requirements depend on the CPU: On some CPUs it isn't
  3459. * necessary at all, on others it won't work at all if not aligned and on others
  3460. * it will work but it will have an impact on performance.
  3461. *
  3462. * In practice, avpkt->data should have 4 byte alignment at minimum and
  3463. * samples should be 16 byte aligned unless the CPU doesn't need it
  3464. * (AltiVec and SSE do).
  3465. *
  3466. * @note Codecs which have the CODEC_CAP_DELAY capability set have a delay
  3467. * between input and output, these need to be fed with avpkt->data=NULL,
  3468. * avpkt->size=0 at the end to return the remaining frames.
  3469. *
  3470. * @param avctx the codec context
  3471. * @param[out] samples the output buffer, sample type in avctx->sample_fmt
  3472. * If the sample format is planar, each channel plane will
  3473. * be the same size, with no padding between channels.
  3474. * @param[in,out] frame_size_ptr the output buffer size in bytes
  3475. * @param[in] avpkt The input AVPacket containing the input buffer.
  3476. * You can create such packet with av_init_packet() and by then setting
  3477. * data and size, some decoders might in addition need other fields.
  3478. * All decoders are designed to use the least fields possible though.
  3479. * @return On error a negative value is returned, otherwise the number of bytes
  3480. * used or zero if no frame data was decompressed (used) from the input AVPacket.
  3481. */
  3482. attribute_deprecated int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,
  3483. int *frame_size_ptr,
  3484. AVPacket *avpkt);
  3485. #endif
  3486. /**
  3487. * Decode the audio frame of size avpkt->size from avpkt->data into frame.
  3488. *
  3489. * Some decoders may support multiple frames in a single AVPacket. Such
  3490. * decoders would then just decode the first frame. In this case,
  3491. * avcodec_decode_audio4 has to be called again with an AVPacket containing
  3492. * the remaining data in order to decode the second frame, etc...
  3493. * Even if no frames are returned, the packet needs to be fed to the decoder
  3494. * with remaining data until it is completely consumed or an error occurs.
  3495. *
  3496. * @warning The input buffer, avpkt->data must be FF_INPUT_BUFFER_PADDING_SIZE
  3497. * larger than the actual read bytes because some optimized bitstream
  3498. * readers read 32 or 64 bits at once and could read over the end.
  3499. *
  3500. * @note You might have to align the input buffer. The alignment requirements
  3501. * depend on the CPU and the decoder.
  3502. *
  3503. * @param avctx the codec context
  3504. * @param[out] frame The AVFrame in which to store decoded audio samples.
  3505. * Decoders request a buffer of a particular size by setting
  3506. * AVFrame.nb_samples prior to calling get_buffer(). The
  3507. * decoder may, however, only utilize part of the buffer by
  3508. * setting AVFrame.nb_samples to a smaller value in the
  3509. * output frame.
  3510. * @param[out] got_frame_ptr Zero if no frame could be decoded, otherwise it is
  3511. * non-zero.
  3512. * @param[in] avpkt The input AVPacket containing the input buffer.
  3513. * At least avpkt->data and avpkt->size should be set. Some
  3514. * decoders might also require additional fields to be set.
  3515. * @return A negative error code is returned if an error occurred during
  3516. * decoding, otherwise the number of bytes consumed from the input
  3517. * AVPacket is returned.
  3518. */
  3519. int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame,
  3520. int *got_frame_ptr, const AVPacket *avpkt);
  3521. /**
  3522. * Decode the video frame of size avpkt->size from avpkt->data into picture.
  3523. * Some decoders may support multiple frames in a single AVPacket, such
  3524. * decoders would then just decode the first frame.
  3525. *
  3526. * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than
  3527. * the actual read bytes because some optimized bitstream readers read 32 or 64
  3528. * bits at once and could read over the end.
  3529. *
  3530. * @warning The end of the input buffer buf should be set to 0 to ensure that
  3531. * no overreading happens for damaged MPEG streams.
  3532. *
  3533. * @note You might have to align the input buffer avpkt->data.
  3534. * The alignment requirements depend on the CPU: on some CPUs it isn't
  3535. * necessary at all, on others it won't work at all if not aligned and on others
  3536. * it will work but it will have an impact on performance.
  3537. *
  3538. * In practice, avpkt->data should have 4 byte alignment at minimum.
  3539. *
  3540. * @note Codecs which have the CODEC_CAP_DELAY capability set have a delay
  3541. * between input and output, these need to be fed with avpkt->data=NULL,
  3542. * avpkt->size=0 at the end to return the remaining frames.
  3543. *
  3544. * @param avctx the codec context
  3545. * @param[out] picture The AVFrame in which the decoded video frame will be stored.
  3546. * Use avcodec_alloc_frame to get an AVFrame, the codec will
  3547. * allocate memory for the actual bitmap.
  3548. * with default get/release_buffer(), the decoder frees/reuses the bitmap as it sees fit.
  3549. * with overridden get/release_buffer() (needs CODEC_CAP_DR1) the user decides into what buffer the decoder
  3550. * decodes and the decoder tells the user once it does not need the data anymore,
  3551. * the user app can at this point free/reuse/keep the memory as it sees fit.
  3552. *
  3553. * @param[in] avpkt The input AVpacket containing the input buffer.
  3554. * You can create such packet with av_init_packet() and by then setting
  3555. * data and size, some decoders might in addition need other fields like
  3556. * flags&AV_PKT_FLAG_KEY. All decoders are designed to use the least
  3557. * fields possible.
  3558. * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero.
  3559. * @return On error a negative value is returned, otherwise the number of bytes
  3560. * used or zero if no frame could be decompressed.
  3561. */
  3562. int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
  3563. int *got_picture_ptr,
  3564. const AVPacket *avpkt);
  3565. /**
  3566. * Decode a subtitle message.
  3567. * Return a negative value on error, otherwise return the number of bytes used.
  3568. * If no subtitle could be decompressed, got_sub_ptr is zero.
  3569. * Otherwise, the subtitle is stored in *sub.
  3570. * Note that CODEC_CAP_DR1 is not available for subtitle codecs. This is for
  3571. * simplicity, because the performance difference is expect to be negligible
  3572. * and reusing a get_buffer written for video codecs would probably perform badly
  3573. * due to a potentially very different allocation pattern.
  3574. *
  3575. * @param avctx the codec context
  3576. * @param[out] sub The AVSubtitle in which the decoded subtitle will be stored, must be
  3577. freed with avsubtitle_free if *got_sub_ptr is set.
  3578. * @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero.
  3579. * @param[in] avpkt The input AVPacket containing the input buffer.
  3580. */
  3581. int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
  3582. int *got_sub_ptr,
  3583. AVPacket *avpkt);
  3584. /**
  3585. * @defgroup lavc_parsing Frame parsing
  3586. * @{
  3587. */
  3588. typedef struct AVCodecParserContext {
  3589. void *priv_data;
  3590. struct AVCodecParser *parser;
  3591. int64_t frame_offset; /* offset of the current frame */
  3592. int64_t cur_offset; /* current offset
  3593. (incremented by each av_parser_parse()) */
  3594. int64_t next_frame_offset; /* offset of the next frame */
  3595. /* video info */
  3596. int pict_type; /* XXX: Put it back in AVCodecContext. */
  3597. /**
  3598. * This field is used for proper frame duration computation in lavf.
  3599. * It signals, how much longer the frame duration of the current frame
  3600. * is compared to normal frame duration.
  3601. *
  3602. * frame_duration = (1 + repeat_pict) * time_base
  3603. *
  3604. * It is used by codecs like H.264 to display telecined material.
  3605. */
  3606. int repeat_pict; /* XXX: Put it back in AVCodecContext. */
  3607. int64_t pts; /* pts of the current frame */
  3608. int64_t dts; /* dts of the current frame */
  3609. /* private data */
  3610. int64_t last_pts;
  3611. int64_t last_dts;
  3612. int fetch_timestamp;
  3613. #define AV_PARSER_PTS_NB 4
  3614. int cur_frame_start_index;
  3615. int64_t cur_frame_offset[AV_PARSER_PTS_NB];
  3616. int64_t cur_frame_pts[AV_PARSER_PTS_NB];
  3617. int64_t cur_frame_dts[AV_PARSER_PTS_NB];
  3618. int flags;
  3619. #define PARSER_FLAG_COMPLETE_FRAMES 0x0001
  3620. #define PARSER_FLAG_ONCE 0x0002
  3621. /// Set if the parser has a valid file offset
  3622. #define PARSER_FLAG_FETCHED_OFFSET 0x0004
  3623. #define PARSER_FLAG_USE_CODEC_TS 0x1000
  3624. int64_t offset; ///< byte offset from starting packet start
  3625. int64_t cur_frame_end[AV_PARSER_PTS_NB];
  3626. /**
  3627. * Set by parser to 1 for key frames and 0 for non-key frames.
  3628. * It is initialized to -1, so if the parser doesn't set this flag,
  3629. * old-style fallback using AV_PICTURE_TYPE_I picture type as key frames
  3630. * will be used.
  3631. */
  3632. int key_frame;
  3633. /**
  3634. * Time difference in stream time base units from the pts of this
  3635. * packet to the point at which the output from the decoder has converged
  3636. * independent from the availability of previous frames. That is, the
  3637. * frames are virtually identical no matter if decoding started from
  3638. * the very first frame or from this keyframe.
  3639. * Is AV_NOPTS_VALUE if unknown.
  3640. * This field is not the display duration of the current frame.
  3641. * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY
  3642. * set.
  3643. *
  3644. * The purpose of this field is to allow seeking in streams that have no
  3645. * keyframes in the conventional sense. It corresponds to the
  3646. * recovery point SEI in H.264 and match_time_delta in NUT. It is also
  3647. * essential for some types of subtitle streams to ensure that all
  3648. * subtitles are correctly displayed after seeking.
  3649. */
  3650. int64_t convergence_duration;
  3651. // Timestamp generation support:
  3652. /**
  3653. * Synchronization point for start of timestamp generation.
  3654. *
  3655. * Set to >0 for sync point, 0 for no sync point and <0 for undefined
  3656. * (default).
  3657. *
  3658. * For example, this corresponds to presence of H.264 buffering period
  3659. * SEI message.
  3660. */
  3661. int dts_sync_point;
  3662. /**
  3663. * Offset of the current timestamp against last timestamp sync point in
  3664. * units of AVCodecContext.time_base.
  3665. *
  3666. * Set to INT_MIN when dts_sync_point unused. Otherwise, it must
  3667. * contain a valid timestamp offset.
  3668. *
  3669. * Note that the timestamp of sync point has usually a nonzero
  3670. * dts_ref_dts_delta, which refers to the previous sync point. Offset of
  3671. * the next frame after timestamp sync point will be usually 1.
  3672. *
  3673. * For example, this corresponds to H.264 cpb_removal_delay.
  3674. */
  3675. int dts_ref_dts_delta;
  3676. /**
  3677. * Presentation delay of current frame in units of AVCodecContext.time_base.
  3678. *
  3679. * Set to INT_MIN when dts_sync_point unused. Otherwise, it must
  3680. * contain valid non-negative timestamp delta (presentation time of a frame
  3681. * must not lie in the past).
  3682. *
  3683. * This delay represents the difference between decoding and presentation
  3684. * time of the frame.
  3685. *
  3686. * For example, this corresponds to H.264 dpb_output_delay.
  3687. */
  3688. int pts_dts_delta;
  3689. /**
  3690. * Position of the packet in file.
  3691. *
  3692. * Analogous to cur_frame_pts/dts
  3693. */
  3694. int64_t cur_frame_pos[AV_PARSER_PTS_NB];
  3695. /**
  3696. * Byte position of currently parsed frame in stream.
  3697. */
  3698. int64_t pos;
  3699. /**
  3700. * Previous frame byte position.
  3701. */
  3702. int64_t last_pos;
  3703. /**
  3704. * Duration of the current frame.
  3705. * For audio, this is in units of 1 / AVCodecContext.sample_rate.
  3706. * For all other types, this is in units of AVCodecContext.time_base.
  3707. */
  3708. int duration;
  3709. } AVCodecParserContext;
  3710. typedef struct AVCodecParser {
  3711. int codec_ids[5]; /* several codec IDs are permitted */
  3712. int priv_data_size;
  3713. int (*parser_init)(AVCodecParserContext *s);
  3714. int (*parser_parse)(AVCodecParserContext *s,
  3715. AVCodecContext *avctx,
  3716. const uint8_t **poutbuf, int *poutbuf_size,
  3717. const uint8_t *buf, int buf_size);
  3718. void (*parser_close)(AVCodecParserContext *s);
  3719. int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size);
  3720. struct AVCodecParser *next;
  3721. } AVCodecParser;
  3722. AVCodecParser *av_parser_next(AVCodecParser *c);
  3723. void av_register_codec_parser(AVCodecParser *parser);
  3724. AVCodecParserContext *av_parser_init(int codec_id);
  3725. /**
  3726. * Parse a packet.
  3727. *
  3728. * @param s parser context.
  3729. * @param avctx codec context.
  3730. * @param poutbuf set to pointer to parsed buffer or NULL if not yet finished.
  3731. * @param poutbuf_size set to size of parsed buffer or zero if not yet finished.
  3732. * @param buf input buffer.
  3733. * @param buf_size input length, to signal EOF, this should be 0 (so that the last frame can be output).
  3734. * @param pts input presentation timestamp.
  3735. * @param dts input decoding timestamp.
  3736. * @param pos input byte position in stream.
  3737. * @return the number of bytes of the input bitstream used.
  3738. *
  3739. * Example:
  3740. * @code
  3741. * while(in_len){
  3742. * len = av_parser_parse2(myparser, AVCodecContext, &data, &size,
  3743. * in_data, in_len,
  3744. * pts, dts, pos);
  3745. * in_data += len;
  3746. * in_len -= len;
  3747. *
  3748. * if(size)
  3749. * decode_frame(data, size);
  3750. * }
  3751. * @endcode
  3752. */
  3753. int av_parser_parse2(AVCodecParserContext *s,
  3754. AVCodecContext *avctx,
  3755. uint8_t **poutbuf, int *poutbuf_size,
  3756. const uint8_t *buf, int buf_size,
  3757. int64_t pts, int64_t dts,
  3758. int64_t pos);
  3759. int av_parser_change(AVCodecParserContext *s,
  3760. AVCodecContext *avctx,
  3761. uint8_t **poutbuf, int *poutbuf_size,
  3762. const uint8_t *buf, int buf_size, int keyframe);
  3763. void av_parser_close(AVCodecParserContext *s);
  3764. /**
  3765. * @}
  3766. * @}
  3767. */
  3768. /**
  3769. * @addtogroup lavc_encoding
  3770. * @{
  3771. */
  3772. /**
  3773. * Find a registered encoder with a matching codec ID.
  3774. *
  3775. * @param id AVCodecID of the requested encoder
  3776. * @return An encoder if one was found, NULL otherwise.
  3777. */
  3778. AVCodec *avcodec_find_encoder(enum AVCodecID id);
  3779. /**
  3780. * Find a registered encoder with the specified name.
  3781. *
  3782. * @param name name of the requested encoder
  3783. * @return An encoder if one was found, NULL otherwise.
  3784. */
  3785. AVCodec *avcodec_find_encoder_by_name(const char *name);
  3786. #if FF_API_OLD_ENCODE_AUDIO
  3787. /**
  3788. * Encode an audio frame from samples into buf.
  3789. *
  3790. * @deprecated Use avcodec_encode_audio2 instead.
  3791. *
  3792. * @note The output buffer should be at least FF_MIN_BUFFER_SIZE bytes large.
  3793. * However, for codecs with avctx->frame_size equal to 0 (e.g. PCM) the user
  3794. * will know how much space is needed because it depends on the value passed
  3795. * in buf_size as described below. In that case a lower value can be used.
  3796. *
  3797. * @param avctx the codec context
  3798. * @param[out] buf the output buffer
  3799. * @param[in] buf_size the output buffer size
  3800. * @param[in] samples the input buffer containing the samples
  3801. * The number of samples read from this buffer is frame_size*channels,
  3802. * both of which are defined in avctx.
  3803. * For codecs which have avctx->frame_size equal to 0 (e.g. PCM) the number of
  3804. * samples read from samples is equal to:
  3805. * buf_size * 8 / (avctx->channels * av_get_bits_per_sample(avctx->codec_id))
  3806. * This also implies that av_get_bits_per_sample() must not return 0 for these
  3807. * codecs.
  3808. * @return On error a negative value is returned, on success zero or the number
  3809. * of bytes used to encode the data read from the input buffer.
  3810. */
  3811. int attribute_deprecated avcodec_encode_audio(AVCodecContext *avctx,
  3812. uint8_t *buf, int buf_size,
  3813. const short *samples);
  3814. #endif
  3815. /**
  3816. * Encode a frame of audio.
  3817. *
  3818. * Takes input samples from frame and writes the next output packet, if
  3819. * available, to avpkt. The output packet does not necessarily contain data for
  3820. * the most recent frame, as encoders can delay, split, and combine input frames
  3821. * internally as needed.
  3822. *
  3823. * @param avctx codec context
  3824. * @param avpkt output AVPacket.
  3825. * The user can supply an output buffer by setting
  3826. * avpkt->data and avpkt->size prior to calling the
  3827. * function, but if the size of the user-provided data is not
  3828. * large enough, encoding will fail. If avpkt->data and
  3829. * avpkt->size are set, avpkt->destruct must also be set. All
  3830. * other AVPacket fields will be reset by the encoder using
  3831. * av_init_packet(). If avpkt->data is NULL, the encoder will
  3832. * allocate it. The encoder will set avpkt->size to the size
  3833. * of the output packet.
  3834. *
  3835. * If this function fails or produces no output, avpkt will be
  3836. * freed using av_free_packet() (i.e. avpkt->destruct will be
  3837. * called to free the user supplied buffer).
  3838. * @param[in] frame AVFrame containing the raw audio data to be encoded.
  3839. * May be NULL when flushing an encoder that has the
  3840. * CODEC_CAP_DELAY capability set.
  3841. * If CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame
  3842. * can have any number of samples.
  3843. * If it is not set, frame->nb_samples must be equal to
  3844. * avctx->frame_size for all frames except the last.
  3845. * The final frame may be smaller than avctx->frame_size.
  3846. * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the
  3847. * output packet is non-empty, and to 0 if it is
  3848. * empty. If the function returns an error, the
  3849. * packet can be assumed to be invalid, and the
  3850. * value of got_packet_ptr is undefined and should
  3851. * not be used.
  3852. * @return 0 on success, negative error code on failure
  3853. */
  3854. int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt,
  3855. const AVFrame *frame, int *got_packet_ptr);
  3856. #if FF_API_OLD_ENCODE_VIDEO
  3857. /**
  3858. * @deprecated use avcodec_encode_video2() instead.
  3859. *
  3860. * Encode a video frame from pict into buf.
  3861. * The input picture should be
  3862. * stored using a specific format, namely avctx.pix_fmt.
  3863. *
  3864. * @param avctx the codec context
  3865. * @param[out] buf the output buffer for the bitstream of encoded frame
  3866. * @param[in] buf_size the size of the output buffer in bytes
  3867. * @param[in] pict the input picture to encode
  3868. * @return On error a negative value is returned, on success zero or the number
  3869. * of bytes used from the output buffer.
  3870. */
  3871. attribute_deprecated
  3872. int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
  3873. const AVFrame *pict);
  3874. #endif
  3875. /**
  3876. * Encode a frame of video.
  3877. *
  3878. * Takes input raw video data from frame and writes the next output packet, if
  3879. * available, to avpkt. The output packet does not necessarily contain data for
  3880. * the most recent frame, as encoders can delay and reorder input frames
  3881. * internally as needed.
  3882. *
  3883. * @param avctx codec context
  3884. * @param avpkt output AVPacket.
  3885. * The user can supply an output buffer by setting
  3886. * avpkt->data and avpkt->size prior to calling the
  3887. * function, but if the size of the user-provided data is not
  3888. * large enough, encoding will fail. All other AVPacket fields
  3889. * will be reset by the encoder using av_init_packet(). If
  3890. * avpkt->data is NULL, the encoder will allocate it.
  3891. * The encoder will set avpkt->size to the size of the
  3892. * output packet. The returned data (if any) belongs to the
  3893. * caller, he is responsible for freeing it.
  3894. *
  3895. * If this function fails or produces no output, avpkt will be
  3896. * freed using av_free_packet() (i.e. avpkt->destruct will be
  3897. * called to free the user supplied buffer).
  3898. * @param[in] frame AVFrame containing the raw video data to be encoded.
  3899. * May be NULL when flushing an encoder that has the
  3900. * CODEC_CAP_DELAY capability set.
  3901. * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the
  3902. * output packet is non-empty, and to 0 if it is
  3903. * empty. If the function returns an error, the
  3904. * packet can be assumed to be invalid, and the
  3905. * value of got_packet_ptr is undefined and should
  3906. * not be used.
  3907. * @return 0 on success, negative error code on failure
  3908. */
  3909. int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,
  3910. const AVFrame *frame, int *got_packet_ptr);
  3911. int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
  3912. const AVSubtitle *sub);
  3913. /**
  3914. * @}
  3915. */
  3916. /**
  3917. * @defgroup lavc_resample Audio resampling
  3918. * @ingroup libavc
  3919. *
  3920. * @{
  3921. */
  3922. struct ReSampleContext;
  3923. struct AVResampleContext;
  3924. typedef struct ReSampleContext ReSampleContext;
  3925. /**
  3926. * Initialize audio resampling context.
  3927. *
  3928. * @param output_channels number of output channels
  3929. * @param input_channels number of input channels
  3930. * @param output_rate output sample rate
  3931. * @param input_rate input sample rate
  3932. * @param sample_fmt_out requested output sample format
  3933. * @param sample_fmt_in input sample format
  3934. * @param filter_length length of each FIR filter in the filterbank relative to the cutoff frequency
  3935. * @param log2_phase_count log2 of the number of entries in the polyphase filterbank
  3936. * @param linear if 1 then the used FIR filter will be linearly interpolated
  3937. between the 2 closest, if 0 the closest will be used
  3938. * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate
  3939. * @return allocated ReSampleContext, NULL if error occurred
  3940. */
  3941. ReSampleContext *av_audio_resample_init(int output_channels, int input_channels,
  3942. int output_rate, int input_rate,
  3943. enum AVSampleFormat sample_fmt_out,
  3944. enum AVSampleFormat sample_fmt_in,
  3945. int filter_length, int log2_phase_count,
  3946. int linear, double cutoff);
  3947. int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
  3948. /**
  3949. * Free resample context.
  3950. *
  3951. * @param s a non-NULL pointer to a resample context previously
  3952. * created with av_audio_resample_init()
  3953. */
  3954. void audio_resample_close(ReSampleContext *s);
  3955. /**
  3956. * Initialize an audio resampler.
  3957. * Note, if either rate is not an integer then simply scale both rates up so they are.
  3958. * @param filter_length length of each FIR filter in the filterbank relative to the cutoff freq
  3959. * @param log2_phase_count log2 of the number of entries in the polyphase filterbank
  3960. * @param linear If 1 then the used FIR filter will be linearly interpolated
  3961. between the 2 closest, if 0 the closest will be used
  3962. * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate
  3963. */
  3964. struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff);
  3965. /**
  3966. * Resample an array of samples using a previously configured context.
  3967. * @param src an array of unconsumed samples
  3968. * @param consumed the number of samples of src which have been consumed are returned here
  3969. * @param src_size the number of unconsumed samples available
  3970. * @param dst_size the amount of space in samples available in dst
  3971. * @param update_ctx If this is 0 then the context will not be modified, that way several channels can be resampled with the same context.
  3972. * @return the number of samples written in dst or -1 if an error occurred
  3973. */
  3974. int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx);
  3975. /**
  3976. * Compensate samplerate/timestamp drift. The compensation is done by changing
  3977. * the resampler parameters, so no audible clicks or similar distortions occur
  3978. * @param compensation_distance distance in output samples over which the compensation should be performed
  3979. * @param sample_delta number of output samples which should be output less
  3980. *
  3981. * example: av_resample_compensate(c, 10, 500)
  3982. * here instead of 510 samples only 500 samples would be output
  3983. *
  3984. * note, due to rounding the actual compensation might be slightly different,
  3985. * especially if the compensation_distance is large and the in_rate used during init is small
  3986. */
  3987. void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance);
  3988. void av_resample_close(struct AVResampleContext *c);
  3989. /**
  3990. * @}
  3991. */
  3992. /**
  3993. * @addtogroup lavc_picture
  3994. * @{
  3995. */
  3996. /**
  3997. * Allocate memory for a picture. Call avpicture_free() to free it.
  3998. *
  3999. * @see avpicture_fill()
  4000. *
  4001. * @param picture the picture to be filled in
  4002. * @param pix_fmt the format of the picture
  4003. * @param width the width of the picture
  4004. * @param height the height of the picture
  4005. * @return zero if successful, a negative value if not
  4006. */
  4007. int avpicture_alloc(AVPicture *picture, enum PixelFormat pix_fmt, int width, int height);
  4008. /**
  4009. * Free a picture previously allocated by avpicture_alloc().
  4010. * The data buffer used by the AVPicture is freed, but the AVPicture structure
  4011. * itself is not.
  4012. *
  4013. * @param picture the AVPicture to be freed
  4014. */
  4015. void avpicture_free(AVPicture *picture);
  4016. /**
  4017. * Fill in the AVPicture fields, always assume a linesize alignment of
  4018. * 1.
  4019. *
  4020. * @see av_image_fill_arrays()
  4021. */
  4022. int avpicture_fill(AVPicture *picture, uint8_t *ptr,
  4023. enum PixelFormat pix_fmt, int width, int height);
  4024. /**
  4025. * Copy pixel data from an AVPicture into a buffer, always assume a
  4026. * linesize alignment of 1.
  4027. *
  4028. * @see av_image_copy_to_buffer()
  4029. */
  4030. int avpicture_layout(const AVPicture* src, enum PixelFormat pix_fmt, int width, int height,
  4031. unsigned char *dest, int dest_size);
  4032. /**
  4033. * Calculate the size in bytes that a picture of the given width and height
  4034. * would occupy if stored in the given picture format.
  4035. * Always assume a linesize alignment of 1.
  4036. *
  4037. * @see av_image_get_buffer_size().
  4038. */
  4039. int avpicture_get_size(enum PixelFormat pix_fmt, int width, int height);
  4040. /**
  4041. * deinterlace - if not supported return -1
  4042. */
  4043. int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
  4044. enum PixelFormat pix_fmt, int width, int height);
  4045. /**
  4046. * Copy image src to dst. Wraps av_image_copy().
  4047. */
  4048. void av_picture_copy(AVPicture *dst, const AVPicture *src,
  4049. enum PixelFormat pix_fmt, int width, int height);
  4050. /**
  4051. * Crop image top and left side.
  4052. */
  4053. int av_picture_crop(AVPicture *dst, const AVPicture *src,
  4054. enum PixelFormat pix_fmt, int top_band, int left_band);
  4055. /**
  4056. * Pad image.
  4057. */
  4058. int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, enum PixelFormat pix_fmt,
  4059. int padtop, int padbottom, int padleft, int padright, int *color);
  4060. /**
  4061. * @}
  4062. */
  4063. /**
  4064. * @defgroup lavc_misc Utility functions
  4065. * @ingroup libavc
  4066. *
  4067. * Miscellaneous utility functions related to both encoding and decoding
  4068. * (or neither).
  4069. * @{
  4070. */
  4071. /**
  4072. * @defgroup lavc_misc_pixfmt Pixel formats
  4073. *
  4074. * Functions for working with pixel formats.
  4075. * @{
  4076. */
  4077. void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int *v_shift);
  4078. /**
  4079. * Return a value representing the fourCC code associated to the
  4080. * pixel format pix_fmt, or 0 if no associated fourCC code can be
  4081. * found.
  4082. */
  4083. unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat pix_fmt);
  4084. #define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */
  4085. #define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */
  4086. #define FF_LOSS_COLORSPACE 0x0004 /**< loss due to color space conversion */
  4087. #define FF_LOSS_ALPHA 0x0008 /**< loss of alpha bits */
  4088. #define FF_LOSS_COLORQUANT 0x0010 /**< loss due to color quantization */
  4089. #define FF_LOSS_CHROMA 0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */
  4090. /**
  4091. * Compute what kind of losses will occur when converting from one specific
  4092. * pixel format to another.
  4093. * When converting from one pixel format to another, information loss may occur.
  4094. * For example, when converting from RGB24 to GRAY, the color information will
  4095. * be lost. Similarly, other losses occur when converting from some formats to
  4096. * other formats. These losses can involve loss of chroma, but also loss of
  4097. * resolution, loss of color depth, loss due to the color space conversion, loss
  4098. * of the alpha bits or loss due to color quantization.
  4099. * avcodec_get_fix_fmt_loss() informs you about the various types of losses
  4100. * which will occur when converting from one pixel format to another.
  4101. *
  4102. * @param[in] dst_pix_fmt destination pixel format
  4103. * @param[in] src_pix_fmt source pixel format
  4104. * @param[in] has_alpha Whether the source pixel format alpha channel is used.
  4105. * @return Combination of flags informing you what kind of losses will occur
  4106. * (maximum loss for an invalid dst_pix_fmt).
  4107. */
  4108. int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_pix_fmt,
  4109. int has_alpha);
  4110. #if FF_API_FIND_BEST_PIX_FMT
  4111. /**
  4112. * @deprecated use avcodec_find_best_pix_fmt_of_2() instead.
  4113. *
  4114. * Find the best pixel format to convert to given a certain source pixel
  4115. * format. When converting from one pixel format to another, information loss
  4116. * may occur. For example, when converting from RGB24 to GRAY, the color
  4117. * information will be lost. Similarly, other losses occur when converting from
  4118. * some formats to other formats. avcodec_find_best_pix_fmt() searches which of
  4119. * the given pixel formats should be used to suffer the least amount of loss.
  4120. * The pixel formats from which it chooses one, are determined by the
  4121. * pix_fmt_mask parameter.
  4122. *
  4123. * Note, only the first 64 pixel formats will fit in pix_fmt_mask.
  4124. *
  4125. * @code
  4126. * src_pix_fmt = PIX_FMT_YUV420P;
  4127. * pix_fmt_mask = (1 << PIX_FMT_YUV422P) | (1 << PIX_FMT_RGB24);
  4128. * dst_pix_fmt = avcodec_find_best_pix_fmt(pix_fmt_mask, src_pix_fmt, alpha, &loss);
  4129. * @endcode
  4130. *
  4131. * @param[in] pix_fmt_mask bitmask determining which pixel format to choose from
  4132. * @param[in] src_pix_fmt source pixel format
  4133. * @param[in] has_alpha Whether the source pixel format alpha channel is used.
  4134. * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur.
  4135. * @return The best pixel format to convert to or -1 if none was found.
  4136. */
  4137. attribute_deprecated
  4138. enum PixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum PixelFormat src_pix_fmt,
  4139. int has_alpha, int *loss_ptr);
  4140. #endif /* FF_API_FIND_BEST_PIX_FMT */
  4141. /**
  4142. * Find the best pixel format to convert to given a certain source pixel
  4143. * format. When converting from one pixel format to another, information loss
  4144. * may occur. For example, when converting from RGB24 to GRAY, the color
  4145. * information will be lost. Similarly, other losses occur when converting from
  4146. * some formats to other formats. avcodec_find_best_pix_fmt_of_2() searches which of
  4147. * the given pixel formats should be used to suffer the least amount of loss.
  4148. * The pixel formats from which it chooses one, are determined by the
  4149. * pix_fmt_list parameter.
  4150. *
  4151. *
  4152. * @param[in] pix_fmt_list PIX_FMT_NONE terminated array of pixel formats to choose from
  4153. * @param[in] src_pix_fmt source pixel format
  4154. * @param[in] has_alpha Whether the source pixel format alpha channel is used.
  4155. * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur.
  4156. * @return The best pixel format to convert to or -1 if none was found.
  4157. */
  4158. enum PixelFormat avcodec_find_best_pix_fmt_of_list(enum PixelFormat *pix_fmt_list,
  4159. enum PixelFormat src_pix_fmt,
  4160. int has_alpha, int *loss_ptr);
  4161. /**
  4162. * Find the best pixel format to convert to given a certain source pixel
  4163. * format and a selection of two destination pixel formats. When converting from
  4164. * one pixel format to another, information loss may occur. For example, when converting
  4165. * from RGB24 to GRAY, the color information will be lost. Similarly, other losses occur when
  4166. * converting from some formats to other formats. avcodec_find_best_pix_fmt_of_2() selects which of
  4167. * the given pixel formats should be used to suffer the least amount of loss.
  4168. *
  4169. * If one of the destination formats is PIX_FMT_NONE the other pixel format (if valid) will be
  4170. * returned.
  4171. *
  4172. * @code
  4173. * src_pix_fmt = PIX_FMT_YUV420P;
  4174. * dst_pix_fmt1= PIX_FMT_RGB24;
  4175. * dst_pix_fmt2= PIX_FMT_GRAY8;
  4176. * dst_pix_fmt3= PIX_FMT_RGB8;
  4177. * loss= FF_LOSS_CHROMA; // don't care about chroma loss, so chroma loss will be ignored.
  4178. * dst_pix_fmt = avcodec_find_best_pix_fmt_of_2(dst_pix_fmt1, dst_pix_fmt2, src_pix_fmt, alpha, &loss);
  4179. * dst_pix_fmt = avcodec_find_best_pix_fmt_of_2(dst_pix_fmt, dst_pix_fmt3, src_pix_fmt, alpha, &loss);
  4180. * @endcode
  4181. *
  4182. * @param[in] dst_pix_fmt1 One of the two destination pixel formats to choose from
  4183. * @param[in] dst_pix_fmt2 The other of the two destination pixel formats to choose from
  4184. * @param[in] src_pix_fmt Source pixel format
  4185. * @param[in] has_alpha Whether the source pixel format alpha channel is used.
  4186. * @param[in, out] loss_ptr Combination of loss flags. In: selects which of the losses to ignore, i.e.
  4187. * NULL or value of zero means we care about all losses. Out: the loss
  4188. * that occurs when converting from src to selected dst pixel format.
  4189. * @return The best pixel format to convert to or -1 if none was found.
  4190. */
  4191. enum PixelFormat avcodec_find_best_pix_fmt_of_2(enum PixelFormat dst_pix_fmt1, enum PixelFormat dst_pix_fmt2,
  4192. enum PixelFormat src_pix_fmt, int has_alpha, int *loss_ptr);
  4193. attribute_deprecated
  4194. #if AV_HAVE_INCOMPATIBLE_FORK_ABI
  4195. enum PixelFormat avcodec_find_best_pix_fmt2(enum PixelFormat *pix_fmt_list,
  4196. enum PixelFormat src_pix_fmt,
  4197. int has_alpha, int *loss_ptr);
  4198. #else
  4199. enum PixelFormat avcodec_find_best_pix_fmt2(enum PixelFormat dst_pix_fmt1, enum PixelFormat dst_pix_fmt2,
  4200. enum PixelFormat src_pix_fmt, int has_alpha, int *loss_ptr);
  4201. #endif
  4202. enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
  4203. /**
  4204. * @}
  4205. */
  4206. void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
  4207. /**
  4208. * Put a string representing the codec tag codec_tag in buf.
  4209. *
  4210. * @param buf_size size in bytes of buf
  4211. * @return the length of the string that would have been generated if
  4212. * enough space had been available, excluding the trailing null
  4213. */
  4214. size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag);
  4215. void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
  4216. /**
  4217. * Return a name for the specified profile, if available.
  4218. *
  4219. * @param codec the codec that is searched for the given profile
  4220. * @param profile the profile value for which a name is requested
  4221. * @return A name for the profile if found, NULL otherwise.
  4222. */
  4223. const char *av_get_profile_name(const AVCodec *codec, int profile);
  4224. int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size);
  4225. int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count);
  4226. //FIXME func typedef
  4227. /**
  4228. * Fill audio frame data and linesize.
  4229. * AVFrame extended_data channel pointers are allocated if necessary for
  4230. * planar audio.
  4231. *
  4232. * @param frame the AVFrame
  4233. * frame->nb_samples must be set prior to calling the
  4234. * function. This function fills in frame->data,
  4235. * frame->extended_data, frame->linesize[0].
  4236. * @param nb_channels channel count
  4237. * @param sample_fmt sample format
  4238. * @param buf buffer to use for frame data
  4239. * @param buf_size size of buffer
  4240. * @param align plane size sample alignment (0 = default)
  4241. * @return 0 on success, negative error code on failure
  4242. */
  4243. int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels,
  4244. enum AVSampleFormat sample_fmt, const uint8_t *buf,
  4245. int buf_size, int align);
  4246. /**
  4247. * Flush buffers, should be called when seeking or when switching to a different stream.
  4248. */
  4249. void avcodec_flush_buffers(AVCodecContext *avctx);
  4250. void avcodec_default_free_buffers(AVCodecContext *s);
  4251. /**
  4252. * Return codec bits per sample.
  4253. *
  4254. * @param[in] codec_id the codec
  4255. * @return Number of bits per sample or zero if unknown for the given codec.
  4256. */
  4257. int av_get_bits_per_sample(enum AVCodecID codec_id);
  4258. /**
  4259. * Return the PCM codec associated with a sample format.
  4260. * @param be endianness, 0 for little, 1 for big,
  4261. * -1 (or anything else) for native
  4262. * @return AV_CODEC_ID_PCM_* or AV_CODEC_ID_NONE
  4263. */
  4264. enum AVCodecID av_get_pcm_codec(enum AVSampleFormat fmt, int be);
  4265. /**
  4266. * Return codec bits per sample.
  4267. * Only return non-zero if the bits per sample is exactly correct, not an
  4268. * approximation.
  4269. *
  4270. * @param[in] codec_id the codec
  4271. * @return Number of bits per sample or zero if unknown for the given codec.
  4272. */
  4273. int av_get_exact_bits_per_sample(enum AVCodecID codec_id);
  4274. /**
  4275. * Return audio frame duration.
  4276. *
  4277. * @param avctx codec context
  4278. * @param frame_bytes size of the frame, or 0 if unknown
  4279. * @return frame duration, in samples, if known. 0 if not able to
  4280. * determine.
  4281. */
  4282. int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes);
  4283. typedef struct AVBitStreamFilterContext {
  4284. void *priv_data;
  4285. struct AVBitStreamFilter *filter;
  4286. AVCodecParserContext *parser;
  4287. struct AVBitStreamFilterContext *next;
  4288. } AVBitStreamFilterContext;
  4289. typedef struct AVBitStreamFilter {
  4290. const char *name;
  4291. int priv_data_size;
  4292. int (*filter)(AVBitStreamFilterContext *bsfc,
  4293. AVCodecContext *avctx, const char *args,
  4294. uint8_t **poutbuf, int *poutbuf_size,
  4295. const uint8_t *buf, int buf_size, int keyframe);
  4296. void (*close)(AVBitStreamFilterContext *bsfc);
  4297. struct AVBitStreamFilter *next;
  4298. } AVBitStreamFilter;
  4299. void av_register_bitstream_filter(AVBitStreamFilter *bsf);
  4300. AVBitStreamFilterContext *av_bitstream_filter_init(const char *name);
  4301. int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc,
  4302. AVCodecContext *avctx, const char *args,
  4303. uint8_t **poutbuf, int *poutbuf_size,
  4304. const uint8_t *buf, int buf_size, int keyframe);
  4305. void av_bitstream_filter_close(AVBitStreamFilterContext *bsf);
  4306. AVBitStreamFilter *av_bitstream_filter_next(AVBitStreamFilter *f);
  4307. /* memory */
  4308. /**
  4309. * Reallocate the given block if it is not large enough, otherwise do nothing.
  4310. *
  4311. * @see av_realloc
  4312. */
  4313. void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size);
  4314. /**
  4315. * Allocate a buffer, reusing the given one if large enough.
  4316. *
  4317. * Contrary to av_fast_realloc the current buffer contents might not be
  4318. * preserved and on error the old buffer is freed, thus no special
  4319. * handling to avoid memleaks is necessary.
  4320. *
  4321. * @param ptr pointer to pointer to already allocated buffer, overwritten with pointer to new buffer
  4322. * @param size size of the buffer *ptr points to
  4323. * @param min_size minimum size of *ptr buffer after returning, *ptr will be NULL and
  4324. * *size 0 if an error occurred.
  4325. */
  4326. void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size);
  4327. /**
  4328. * Same behaviour av_fast_malloc but the buffer has additional
  4329. * FF_INPUT_PADDING_SIZE at the end which will will always be 0.
  4330. *
  4331. * In addition the whole buffer will initially and after resizes
  4332. * be 0-initialized so that no uninitialized data will ever appear.
  4333. */
  4334. void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size);
  4335. /**
  4336. * Same behaviour av_fast_padded_malloc except that buffer will always
  4337. * be 0-initialized after call.
  4338. */
  4339. void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size);
  4340. /**
  4341. * Encode extradata length to a buffer. Used by xiph codecs.
  4342. *
  4343. * @param s buffer to write to; must be at least (v/255+1) bytes long
  4344. * @param v size of extradata in bytes
  4345. * @return number of bytes written to the buffer.
  4346. */
  4347. unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
  4348. /**
  4349. * Log a generic warning message about a missing feature. This function is
  4350. * intended to be used internally by FFmpeg (libavcodec, libavformat, etc.)
  4351. * only, and would normally not be used by applications.
  4352. * @param[in] avc a pointer to an arbitrary struct of which the first field is
  4353. * a pointer to an AVClass struct
  4354. * @param[in] feature string containing the name of the missing feature
  4355. * @param[in] want_sample indicates if samples are wanted which exhibit this feature.
  4356. * If want_sample is non-zero, additional verbage will be added to the log
  4357. * message which tells the user how to report samples to the development
  4358. * mailing list.
  4359. */
  4360. void av_log_missing_feature(void *avc, const char *feature, int want_sample);
  4361. /**
  4362. * Log a generic warning message asking for a sample. This function is
  4363. * intended to be used internally by FFmpeg (libavcodec, libavformat, etc.)
  4364. * only, and would normally not be used by applications.
  4365. * @param[in] avc a pointer to an arbitrary struct of which the first field is
  4366. * a pointer to an AVClass struct
  4367. * @param[in] msg string containing an optional message, or NULL if no message
  4368. */
  4369. void av_log_ask_for_sample(void *avc, const char *msg, ...) av_printf_format(2, 3);
  4370. /**
  4371. * Register the hardware accelerator hwaccel.
  4372. */
  4373. void av_register_hwaccel(AVHWAccel *hwaccel);
  4374. /**
  4375. * If hwaccel is NULL, returns the first registered hardware accelerator,
  4376. * if hwaccel is non-NULL, returns the next registered hardware accelerator
  4377. * after hwaccel, or NULL if hwaccel is the last one.
  4378. */
  4379. AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel);
  4380. /**
  4381. * Lock operation used by lockmgr
  4382. */
  4383. enum AVLockOp {
  4384. AV_LOCK_CREATE, ///< Create a mutex
  4385. AV_LOCK_OBTAIN, ///< Lock the mutex
  4386. AV_LOCK_RELEASE, ///< Unlock the mutex
  4387. AV_LOCK_DESTROY, ///< Free mutex resources
  4388. };
  4389. /**
  4390. * Register a user provided lock manager supporting the operations
  4391. * specified by AVLockOp. mutex points to a (void *) where the
  4392. * lockmgr should store/get a pointer to a user allocated mutex. It's
  4393. * NULL upon AV_LOCK_CREATE and != NULL for all other ops.
  4394. *
  4395. * @param cb User defined callback. Note: FFmpeg may invoke calls to this
  4396. * callback during the call to av_lockmgr_register().
  4397. * Thus, the application must be prepared to handle that.
  4398. * If cb is set to NULL the lockmgr will be unregistered.
  4399. * Also note that during unregistration the previously registered
  4400. * lockmgr callback may also be invoked.
  4401. */
  4402. int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op));
  4403. /**
  4404. * Get the type of the given codec.
  4405. */
  4406. enum AVMediaType avcodec_get_type(enum AVCodecID codec_id);
  4407. /**
  4408. * Get the name of a codec.
  4409. * @return a static string identifying the codec; never NULL
  4410. */
  4411. const char *avcodec_get_name(enum AVCodecID id);
  4412. /**
  4413. * @return a positive value if s is open (i.e. avcodec_open2() was called on it
  4414. * with no corresponding avcodec_close()), 0 otherwise.
  4415. */
  4416. int avcodec_is_open(AVCodecContext *s);
  4417. /**
  4418. * @return a non-zero number if codec is an encoder, zero otherwise
  4419. */
  4420. int av_codec_is_encoder(const AVCodec *codec);
  4421. /**
  4422. * @return a non-zero number if codec is a decoder, zero otherwise
  4423. */
  4424. int av_codec_is_decoder(const AVCodec *codec);
  4425. /**
  4426. * @return descriptor for given codec ID or NULL if no descriptor exists.
  4427. */
  4428. const AVCodecDescriptor *avcodec_descriptor_get(enum AVCodecID id);
  4429. /**
  4430. * Iterate over all codec descriptors known to libavcodec.
  4431. *
  4432. * @param prev previous descriptor. NULL to get the first descriptor.
  4433. *
  4434. * @return next descriptor or NULL after the last descriptor
  4435. */
  4436. const AVCodecDescriptor *avcodec_descriptor_next(const AVCodecDescriptor *prev);
  4437. /**
  4438. * @return codec descriptor with the given name or NULL if no such descriptor
  4439. * exists.
  4440. */
  4441. const AVCodecDescriptor *avcodec_descriptor_get_by_name(const char *name);
  4442. /**
  4443. * @}
  4444. */
  4445. #endif /* AVCODEC_AVCODEC_H */