avcodec.h 168 KB

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