avcodec.h 161 KB

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