First, FFmpeg decoding process:
1, register all container formats and Codec:avcodec_register_all (),
2, find the corresponding decoder: Avcodec_find_decoder (av_codec_id_ MJPEG);
3, allocating codec parameter data structure AVCODEC_ALLOC_CONTEXT3 (Avcodec *codec);
4, for partial codecs the data structures that are allocated in the previous step are initialized because some parameters are not valid in the video stream;
5, Open codec: Avcodec_open2 (Avcodeccontext *ctx, Avcodec *codec, NULL);
6, allocating memory for decoded frames: avframe *frame = Av_frame_alloc (
7, initialize the codec input data structure Avpacket:av_init_packet (Avpacket *packet),
8, put compressed video data to be decoded into data structure Avpacket:
(Avpacket) Packet.data = Inbuf (to be decoded video data cache);
(avpacket) packet.size = inbufsize (length of video data to be decoded);
9, call decoding function to start decoding: Avcodec_decode_ Video2 (avcodeccontext *ctx,avframe *frame,int *got,avpacket);
10, a copy of the decoded frame of data, decoded data format according to the data format before the decoding, for example, USB Camera MJPEG Data decoding is the yuv422p format, H264 format data decoding is the yuv420p format, the decoded data stored in the AVFRAME structure to the cache, stored in the way: (Avframe) frame->data[0] Point y component, (avframe) frame->data[1] point U component, (avframe) frame->data[2] point to V component; (Avframe) frame->linesize[0], (avframe) Frame->linesize[1], (avframe) frame->linesize[2] are the lengths of the Y, U, v components per line.
Ii. problems arising from transplant ffmpeg
1, the installation directory ffmpeg/include/libutil/common.h the header file error:
(1) Error: #error missing-d__stdc_constant_macros/#define __stdc_constant_macros
(2) Error: ' Uint64_c ' is not declared into this scope
Error: Common.h header file has the following conditional compilation:
#if defined (__cplusplus) &&!defined (__stdc_constant_macros) &&!defined (uint64_c)
error missing -d__stdc_constant_macros/#define __stdc_constant_macros
#endif
The conditional compilation tells the developer to define the __stdc_constant_macros in the C + + environment and also needs to define the Uint64_c.
2. Workaround: Add the following in the Common.h header file
#define __stdc_constant_macros
#define uint64_c (value) __concat (value,ull)