1*fb1b10abSAndroid Build Coastguard Worker/*! \page usage_decode Decoding 2*fb1b10abSAndroid Build Coastguard Worker 3*fb1b10abSAndroid Build Coastguard Worker The vpx_codec_decode() function is at the core of the decode loop. It 4*fb1b10abSAndroid Build Coastguard Worker processes packets of compressed data passed by the application, producing 5*fb1b10abSAndroid Build Coastguard Worker decoded images. The decoder expects packets to comprise exactly one image 6*fb1b10abSAndroid Build Coastguard Worker frame of data. Packets \ref MUST be passed in decode order. If the 7*fb1b10abSAndroid Build Coastguard Worker application wishes to associate some data with the frame, the 8*fb1b10abSAndroid Build Coastguard Worker <code>user_priv</code> member may be set. The <code>deadline</code> 9*fb1b10abSAndroid Build Coastguard Worker parameter controls the amount of time in microseconds the decoder should 10*fb1b10abSAndroid Build Coastguard Worker spend working on the frame. This is typically used to support adaptive 11*fb1b10abSAndroid Build Coastguard Worker \ref usage_postproc based on the amount of free CPU time. For more 12*fb1b10abSAndroid Build Coastguard Worker information on the <code>deadline</code> parameter, see \ref usage_deadline. 13*fb1b10abSAndroid Build Coastguard Worker 14*fb1b10abSAndroid Build Coastguard Worker \if samples 15*fb1b10abSAndroid Build Coastguard Worker \ref samples 16*fb1b10abSAndroid Build Coastguard Worker \endif 17*fb1b10abSAndroid Build Coastguard Worker 18*fb1b10abSAndroid Build Coastguard Worker 19*fb1b10abSAndroid Build Coastguard Worker \section usage_cb Callback Based Decoding 20*fb1b10abSAndroid Build Coastguard Worker There are two methods for the application to access decoded frame data. Some 21*fb1b10abSAndroid Build Coastguard Worker codecs support asynchronous (callback-based) decoding \ref usage_features 22*fb1b10abSAndroid Build Coastguard Worker that allow the application to register a callback to be invoked by the 23*fb1b10abSAndroid Build Coastguard Worker decoder when decoded data becomes available. Decoders are not required to 24*fb1b10abSAndroid Build Coastguard Worker support this feature, however. Like all \ref usage_features, support can be 25*fb1b10abSAndroid Build Coastguard Worker determined by calling vpx_codec_get_caps(). Callbacks are available in both 26*fb1b10abSAndroid Build Coastguard Worker frame-based and slice-based variants. Frame based callbacks conform to the 27*fb1b10abSAndroid Build Coastguard Worker signature of #vpx_codec_put_frame_cb_fn_t and are invoked once the entire 28*fb1b10abSAndroid Build Coastguard Worker frame has been decoded. Slice based callbacks conform to the signature of 29*fb1b10abSAndroid Build Coastguard Worker #vpx_codec_put_slice_cb_fn_t and are invoked after a subsection of the frame 30*fb1b10abSAndroid Build Coastguard Worker is decoded. For example, a slice callback could be issued for each 31*fb1b10abSAndroid Build Coastguard Worker macroblock row. However, the number and size of slices to return is 32*fb1b10abSAndroid Build Coastguard Worker implementation specific. Also, the image data passed in a slice callback is 33*fb1b10abSAndroid Build Coastguard Worker not necessarily in the same memory segment as the data will be when it is 34*fb1b10abSAndroid Build Coastguard Worker assembled into a full frame. For this reason, the application \ref MUST 35*fb1b10abSAndroid Build Coastguard Worker examine the rectangles that describe what data is valid to access and what 36*fb1b10abSAndroid Build Coastguard Worker data has been updated in this call. For all their additional complexity, 37*fb1b10abSAndroid Build Coastguard Worker slice based decoding callbacks provide substantial speed gains to the 38*fb1b10abSAndroid Build Coastguard Worker overall application in some cases, due to improved cache behavior. 39*fb1b10abSAndroid Build Coastguard Worker 40*fb1b10abSAndroid Build Coastguard Worker 41*fb1b10abSAndroid Build Coastguard Worker \section usage_frame_iter Frame Iterator Based Decoding 42*fb1b10abSAndroid Build Coastguard Worker If the codec does not support callback based decoding, or the application 43*fb1b10abSAndroid Build Coastguard Worker chooses not to make use of that feature, decoded frames are made available 44*fb1b10abSAndroid Build Coastguard Worker through the vpx_codec_get_frame() iterator. The application initializes the 45*fb1b10abSAndroid Build Coastguard Worker iterator storage (of type #vpx_codec_iter_t) to NULL, then calls 46*fb1b10abSAndroid Build Coastguard Worker vpx_codec_get_frame repeatedly until it returns NULL, indicating that all 47*fb1b10abSAndroid Build Coastguard Worker images have been returned. This process may result in zero, one, or many 48*fb1b10abSAndroid Build Coastguard Worker frames that are ready for display, depending on the codec. 49*fb1b10abSAndroid Build Coastguard Worker 50*fb1b10abSAndroid Build Coastguard Worker 51*fb1b10abSAndroid Build Coastguard Worker \section usage_postproc Postprocessing 52*fb1b10abSAndroid Build Coastguard Worker Postprocessing is a process that is applied after a frame is decoded to 53*fb1b10abSAndroid Build Coastguard Worker enhance the image's appearance by removing artifacts introduced in the 54*fb1b10abSAndroid Build Coastguard Worker compression process. It is not required to properly decode the frame, and 55*fb1b10abSAndroid Build Coastguard Worker is generally done only when there is enough spare CPU time to execute 56*fb1b10abSAndroid Build Coastguard Worker the required filters. Codecs may support a number of different 57*fb1b10abSAndroid Build Coastguard Worker postprocessing filters, and the available filters may differ from platform 58*fb1b10abSAndroid Build Coastguard Worker to platform. Embedded devices often do not have enough CPU to implement 59*fb1b10abSAndroid Build Coastguard Worker postprocessing in software. The filter selection is generally handled 60*fb1b10abSAndroid Build Coastguard Worker automatically by the codec, depending on the amount of time remaining before 61*fb1b10abSAndroid Build Coastguard Worker hitting the user-specified \ref usage_deadline after decoding the frame. 62*fb1b10abSAndroid Build Coastguard Worker 63*fb1b10abSAndroid Build Coastguard Worker 64*fb1b10abSAndroid Build Coastguard Worker*/ 65