FFmpeg总结三AV系列结构体之AVCodecContext.docx
《FFmpeg总结三AV系列结构体之AVCodecContext.docx》由会员分享,可在线阅读,更多相关《FFmpeg总结三AV系列结构体之AVCodecContext.docx(57页珍藏版)》请在冰豆网上搜索。
![FFmpeg总结三AV系列结构体之AVCodecContext.docx](https://file1.bdocx.com/fileroot1/2023-2/1/5485bb30-743b-46ce-92e8-dc3559b7ef56/5485bb30-743b-46ce-92e8-dc3559b7ef561.gif)
FFmpeg总结三AV系列结构体之AVCodecContext
FFmpeg总结(三)AV系列结构体之AVCodecContext
描述:
主要扩展API的结构体
Newfieldscanbeaddedtotheendwithminorversionbumps.Removal,reorderingandchangestoexistingfieldsrequireamajorversionbump.YoucanuseAVOptions(av_opt*/av_set/get*())toaccessthesefieldsfromuserapplications.ThenamestringforAVOptionsoptionsmatchestheassociatedcommandlineparameternameandcanbefoundinlibavcodec/options_table.hTheAVOption/commandlineparameternamesdifferinsomecasesfromtheCstructurefieldnamesforhistoricreasonsorbrevity.sizeof(AVCodecContext)mustnotbeusedoutsidelibav*.
typedefstructAVCodecContext{
/**
*informationonstructforav_log
*-setbyavcodec_alloc_context3
*/
constAVClass*av_class;
intlog_level_offset;
enumAVMediaTypecodec_type;/*seeAVMEDIA_TYPE_xxx*/
conststructAVCodec*codec;
#ifFF_API_CODEC_NAME
/**
*@deprecatedthisfieldisnotusedforanythinginlibavcodec
*/
attribute_deprecated
charcodec_name[32];
#endif
enumAVCodecIDcodec_id;/*seeAV_CODEC_ID_xxx*/
/**
*fourcc(LSBfirst,so"ABCD"->('D'<<24)+('C'<<16)+('B'<<8)+'A').
*Thisisusedtoworkaroundsomeencoderbugs.
*Ademuxershouldsetthistowhatisstoredinthefieldusedtoidentifythecodec.
*Iftherearemultiplesuchfieldsinacontainerthenthedemuxershouldchoosetheone
*whichmaximizestheinformationabouttheusedcodec.
*Ifthecodectagfieldinacontainerislargerthan32bitsthenthedemuxershould
*remapthelongerIDto32bitswithatableorotherstructure.Alternativelyanew
*extra_codec_tag+sizecouldbeaddedbutforthisaclearadvantagemustbedemonstrated
*first.
*-encoding:
Setbyuser,ifnotthenthedefaultbasedoncodec_idwillbeused.
*-decoding:
Setbyuser,willbeconvertedtouppercasebylibavcodecduringinit.
*/
unsignedintcodec_tag;
#ifFF_API_STREAM_CODEC_TAG
/**
*@deprecatedthisfieldisunused
*/
attribute_deprecated
unsignedintstream_codec_tag;
#endif
void*priv_data;
/**
*Privatecontextusedforinternaldata.
*
*Unlikepriv_data,thisisnotcodec-specific.Itisusedingeneral
*libavcodecfunctions.
*/
structAVCodecInternal*internal;
/**
*Privatedataoftheuser,canbeusedtocarryappspecificstuff.
*-encoding:
Setbyuser.
*-decoding:
Setbyuser.
*/
void*opaque;
/**
*theaveragebitrate
*-encoding:
Setbyuser;unusedforconstantquantizerencoding.
*-decoding:
Setbyuser,maybeoverwrittenbylibavcodec
*ifthisinfoisavailableinthestream
*/
int64_tbit_rate;
/**
*numberofbitsthebitstreamisallowedtodivergefromthereference.
*thereferencecanbeCBR(forCBRpass1)orVBR(forpass2)
*-encoding:
Setbyuser;unusedforconstantquantizerencoding.
*-decoding:
unused
*/
intbit_rate_tolerance;
/**
*Globalqualityforcodecswhichcannotchangeitperframe.
*ThisshouldbeproportionaltoMPEG-1/2/4qscale.
*-encoding:
Setbyuser.
*-decoding:
unused
*/
intglobal_quality;
/**
*-encoding:
Setbyuser.
*-decoding:
unused
*/
intcompression_level;
#defineFF_COMPRESSION_DEFAULT-1
/**
*AV_CODEC_FLAG_*.
*-encoding:
Setbyuser.
*-decoding:
Setbyuser.
*/
intflags;
/**
*AV_CODEC_FLAG2_*
*-encoding:
Setbyuser.
*-decoding:
Setbyuser.
*/
intflags2;
/**
*somecodecsneed/canuseextradatalikeHuffmantables.
*MJPEG:
Huffmantables
*rv10:
additionalflags
*MPEG-4:
globalheaders(theycanbeinthebitstreamorhere)
*TheallocatedmemoryshouldbeAV_INPUT_BUFFER_PADDING_SIZEbyteslarger
*thanextradata_sizetoavoidproblemsifitisreadwiththebitstreamreader.
*ThebytewisecontentsofextradatamustnotdependonthearchitectureorCPUendianness.
*-encoding:
Set/allocated/freedbylibavcodec.
*-decoding:
Set/allocated/freedbyuser.
*/
uint8_t*extradata;
intextradata_size;
/**
*Thisisthefundamentalunitoftime(inseconds)interms
*ofwhichframetimestampsarerepresented.Forfixed-fpscontent,
*timebaseshouldbe1/framerateandtimestampincrementsshouldbe
*identically1.
*Thisoften,butnotalwaysistheinverseoftheframerateorfieldrate
*forvideo.1/time_baseisnottheaverageframerateiftheframerateisnot
*constant.
*
*Likecontainers,elementarystreamsalsocanstoretimestamps,1/time_base
*istheunitinwhichthesetimestampsarespecified.
*AsexampleofsuchcodectimebaseseeISO/IEC14496-2:
2001(E)
*vop_time_increment_resolutionandfixed_vop_rate
*(fixed_vop_rate==0impliesthatitisdifferentfromtheframerate)
*
*-encoding:
MUSTbesetbyuser.
*-decoding:
theuseofthisfieldfordecodingisdeprecated.
*Useframerateinstead.
*/
AVRationaltime_base;
/**
*Forsomecodecs,thetimebaseisclosertothefieldratethantheframerate.
*Mostnotably,H.264andMPEG-2specifytime_baseashalfofframeduration
*ifnotelecineisused...
*
*Settotime_baseticksperframe.Default1,e.g.,H.264/MPEG-2setitto2.
*/
intticks_per_frame;
/**
*Codecdelay.
*
*Encoding:
Numberofframesdelaytherewillbefromtheencoderinputto
*thedecoderoutput.(weassumethedecodermatchesthespec)
*Decoding:
Numberofframesdelayinadditiontowhatastandarddecoder
*asspecifiedinthespecwouldproduce.
*
*Video:
*Numberofframesthedecodedoutputwillbedelayedrelativetothe
*encodedinput.
*
*Audio:
*Forencoding,thisfieldisunused(seeinitial_padding).
*
*Fordecoding,thisisthenumberofsamplesthedecoderneedsto
*outputbeforethedecoder'soutputisvalid.Whenseeking,youshould
*startdecodingthismanysamplespriortoyourdesiredseekpoint.
*
*-encoding:
Setbylibavcodec.
*-decoding:
Setbylibavcodec.
*/
intdelay;
/*videoonly*/
/**
*picturewidth/height.
*
*@noteThosefieldsmaynotmatchthevaluesofthelast
*AVFrameoutputbyavcodec_decode_video2dueframe
*reordering.
*
*-encoding:
MUSTbesetbyuser.
*-decoding:
Maybesetbytheuserbeforeopeningthedecoderifknowne.g.
*fromthecontainer.Somedecoderswillrequirethedimensions
*tobesetbythecaller.Duringdecoding,thedecodermay
*overwritethosevaluesasrequiredwhileparsingthedata.
*/
intwidth,height;
/**
*Bitstreamwidth/height,maybedifferentfromwidth/heighte.g.when
*thedecodedframeiscroppedbeforebeingoutputorlowresisenabled.
*
*@noteThosefieldmaynotmatchthevalueofthelast
*AVFrameoutputbyavcodec_receive_frame()dueframe
*reordering.
*
*-encoding:
unused
*-decoding:
Maybesetbytheuserbeforeopeningthedecoderifknown
*e.g.fromthecontainer.Duringdecoding,thedecodermay
*overwritethosevaluesasrequiredwhileparsingthedata.
*/
intcoded_width,coded_height;
#ifFF_API_ASPECT_EXTENDED
#defineFF_ASPECT_EXTENDED15
#endif
/**
*thenumberofpicturesinagroupofpictures,or0forintra_only
*-encoding:
Setbyuser.
*-decoding:
unused
*/
intgop_size;
/**
*Pixelformat,seeAV_PIX_FMT_xxx.
*Maybesetbythedemuxerifknownfromheaders.
*Maybeoverriddenbythedecoderifitknowsbetter.
*
*@noteThisfieldmaynotmatchthevalueofthelast
*AVFrameoutputbyavcodec_receive_frame()dueframe
*reordering.
*
*-encoding:
Setbyuser.
*-decoding:
Setbyuserifknown,overriddenbylibavcodecwhile
*parsingthedata.
*/
enumAVPixelFormatpix_fmt;
#ifFF_API_MOTION_EST
/**
*Thisoptiondoesnothing
*@deprecatedusecodecprivateoptionsinstead
*/
attribute_deprecatedintme_method;
#endif
/**
*IfnonNULL,'draw_horiz_band'iscalledbythelibavcodec
*decodertodrawahorizontalband.Itimprovescacheusage.Not
*allcodecscandothat.Youmustcheckthecodeccapabilities
*beforehand.
*Whenmultithreadingisused,itmaybecalledfrommultiplethreads
*atthesametime;threadsmightdrawdifferentpartsofthesameAVFrame,
*ormultipleAVFrames,andthereisnoguaranteethatsliceswillbedrawn
*inorder.
*ThefunctionisalsousedbyhardwareaccelerationAPIs.
*Itiscalledatleastonceduringframedecodingtopass
*thedataneededforhardwarerender.
*Inthatmodeinsteadofpixeldata,AVFramepointsto
*astructurespecifictotheaccelerationAPI.Theapplication
*readsthestructureandcanchangesomefieldstoindicateprogress
*ormarkstate.
*-encoding:
unused
*-decoding:
Setbyuser.
*@paramheighttheheightoftheslice
*@paramytheypositionoftheslice
*@paramtype1->topfield,2->bottomfield,3->frame
*@paramoffsetoffsetintotheAVFrame.datafromwhichthesliceshouldberead
*/
void(*draw_horiz_band)(structAVCodecContext*s,
constAVFrame*src,intoffset[AV_NUM_DATA_POINTERS],
inty,inttype,intheight);
/**
*callbacktonegotiatethepixelFormat
*@paramfmtisthelistofformatswhicharesupportedbythecodec,
*itisterminatedby-1as0isavalidformat,theformatsareorderedbyquality.
*Thefirstisalwaysthenativeone.
*@noteThecallbackmaybecalledagainimmediatelyifinitializationfor
*theselected(hardware-accelerated)pixelformatfailed.
*@warningBehaviorisundefinedifthecallbackreturnsavaluenot
*inthefmtlistofformats.
*@returnthechosenformat
*-encoding:
unused
*-decoding:
Setbyuser,ifnotsetthenativeformatwillbechosen.
*/
enumAVPixelFormat(*get_format)(structAVCodecContext*s,constenumAVPixelFormat*fmt);
/**
*maximumnumberofB-framesbet