You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

avcodec.h 176KB

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