Recently in learning Ffplay source knowledge, on-line about Ffplay is the old version of the sdl1.x version based, so that their own understanding of the analysis of the ffpaly3.2.4 (based on the SDL2) source, and recorded for their own later review. If there is an understanding error, please correct me. 1, the overall framework:
The function call graph for Ffplay in the ffmpeg3.2.4 version is as follows:
Avdevice_register_all () This ffmpeg device is initialized and registered.
Av_register_all () initializes the Libavformat and registers all muxers, Demuxers, and protocols.
Avformat_network_init () Registers the network transport protocol associated with initializing the network.
Init_opts () initializes the command-line options.
Show_banner () displays video information.
Parse_options () parses the command-line arguments.
Sdl_init () initializes the SDL.
Stream_open () Opens the video for processing.
Event_loop () displays video and captures relevant SDL events.
2, Ffpaly thread ffplay in a total of 5 threads, a re-use thread, three decoding thread, and a display thread. reusability Thread: read_thread--> av_read_frame--> packet_queue_put Audio decoding thread: audio_thread--> decoder_decode_frame --Frame_queue_push video decoding thread:video_thread--> get_video_frame--> queue_picture subtitle decoding thread: subtitile_t hread--> decoder_decode_frame--> frame_queue_push Display thread: event_loop--> refresh_loop_wait_event--> V Ideo_refresh--> video_display Step: Ffplay First calls the Read_thread function for de-multiplexing, then stores the de-multiplexed packet in Packetqueue and creates three decoding threads. Three decoding threads remove Avpacket data from their respective packetqueue to decode, get avframe frame data, and then store the decoding frame in Framequeue. The display thread pulls the Avframe frame data from the Framequeue and calls the SDL for display.