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

avcodec.h 177KB

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