当前位置:网站首页>Analysis of openh264 decoded data flow
Analysis of openh264 decoded data flow
2022-07-05 19:40:00 【Hui's technical notes】
openh264dec in finish_frame Logic and avviddec It's simpler , stay handle_frame in ,buffer First send it to the decoder for decoding (DecodeFrameNoDelay
), And then call gst_video_decoder_finish_frame
Will decode the buffer Send to downstream.
DecodeFrameNoDelay decode , return yuvdata, After completion unmap input_buffer:
openh264dec->decoder->DecodeFrameNoDelay (map_info.data, map_info.size,
yuvdata, &dst_buf_info);
gst_buffer_unmap (frame->input_buffer, &map_info);
gst_video_frame_map The function of
gst_video_frame_map() Will be in GstVideoFrame Fill in the structure buffer Pixels and all kinds of video information required .
gboolean
gst_video_frame_map (GstVideoFrame * frame, GstVideoInfo * info, GstBuffer * buffer, GstMapFlags flags)
Use @info and @buffer To fill in @frame, The address will be passed to the #GstVideoFrame structure .
You can use the accessor macro to access , Such as :
GST_VIDEO_FRAME_COMP_DATA()
GST_VIDEO_FRAME_PLANE_DATA()
GST_VIDEO_FRAME_COMP_STRIDE()
GST_VIDEO_FRAME_PLANE_STRIDE()
The purpose of this function is to make it easy for you to get video pixels , Don't worry about too many details .
For example, is video data allocated in a continuous memory block or multiple memory blocks ( for example , For each of these plane There is a memory block ), Or whether to use customization strides And customization plane The offset ( By GstVideoMeta Record ).
This function just fills in with the correct value #GstVideoFrame structure
, Use accessor macros , Data can be easily accessed . It also maps the underlying memory blocks for you .
gst_video_frame_map Use of from ffmpeg avviddec and openh264dec You can also see the implementation of , It is convenient to put the data decoded by the decoder into plane In the memory block .
GstVideoFrame The definition of
/** * GstVideoFrame: * @info: the #GstVideoInfo * @flags: #GstVideoFrameFlags for the frame * @buffer: the mapped GstBuffer's buffer * @meta: pointer to metadata if any * @id: id of the mapped frame. the id can for example be used to * identify the frame in case of multiview video. * @data: pointers to the plane data * @map: mappings of the planes * * A video frame obtained from gst_video_frame_map() */
struct _GstVideoFrame {
GstVideoInfo info;
GstVideoFrameFlags flags;
GstBuffer *buffer;
gpointer meta;
gint id;
gpointer data[GST_VIDEO_MAX_PLANES];
GstMapInfo map[GST_VIDEO_MAX_PLANES];
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
};
gst_video_decoder_allocate_output_frame
Auxiliary function , by @decoder Current #GstVideoCodecState Allocate a buffer to hold a video frame . The subclass should have configured the video state and set src pad caps. from openH264dec and avdec_h264 You can see , Finally, the decoded data must first allocate_output_frame, then copy Data into this ,avviddec The processing inside needs to see get_output_buffer Implementation of function .
gst_video_decoder_finish_frame
stay openh264dec in , adopt gst_video_decoder_finish_frame
Decoded data push To downstream, If no output data is provided ,frame Be regarded as skipped. In any case ,frame Are considered finished and released.
gst_openh264dec_handle_frame
- received frame Then hand it over to openh264dec decode ->DecodeFrameNoDelay
- gst_video_frame_map: mapping frame->output_buffer, What will be decoded yuvdata Fill in .
- gst_video_decoder_set_output_state: stay srcpad Create a new codec state As the output state of the decoder
- gst_video_decoder_finish_frame Send to downstream
because output state Part of the configuration is I420, So we are doing data copy When , yes yuv successively copy:
// i = 0; Y plane
// i = 1; U plane
// i = 2; V plane
for (i = 0; i < 3; i++) {
p = GST_VIDEO_FRAME_COMP_DATA (&video_frame, i);
row_stride = GST_VIDEO_FRAME_COMP_STRIDE (&video_frame, i);
component_width = GST_VIDEO_FRAME_COMP_WIDTH (&video_frame, i);
component_height = GST_VIDEO_FRAME_COMP_HEIGHT (&video_frame, i);
src_width =
i <
1 ? dst_buf_info.UsrData.sSystemBuffer.
iStride[0] : dst_buf_info.UsrData.sSystemBuffer.iStride[1];
for (row = 0; row < component_height; row++) {
memcpy (p, yuvdata[i], component_width);
p += row_stride;
yuvdata[i] += src_width;
}
}
边栏推荐
- 大厂面试必备技能,2022Android不死我不倒
- UWB ultra wideband positioning technology, real-time centimeter level high-precision positioning application, ultra wideband transmission technology
- What is the core value of testing?
- 【obs】libobs-winrt :CreateDispatcherQueueController
- Oracle fault handling: ora-10873:file * needs to be either taken out of backup or media recovered
- Recommended collection, my Tencent Android interview experience sharing
- 中国银河证券开户安全吗 证券开户
- Mysql如何对json数据进行查询及修改
- 软件测试是干什么的?学习有啥要求?
- MMO项目学习一:预热
猜你喜欢
通过POI追加数据到excel中小案例
力扣 729. 我的日程安排表 I
微波雷达感应模块技术,实时智能检测人体存在,静止微小动静感知
Oracle fault handling: ora-10873:file * needs to be either taken out of backup or media recovered
Debezium系列之:记录mariadb数据库删除多张临时表debezium解析到的消息以及解决方法
【AI 框架基础技术】自动求导机制 (Autograd)
如何实现游戏中的在线计时器和离线计时器
Zhongang Mining: analysis of the current market supply situation of the global fluorite industry in 2022
Reinforcement learning - learning notes 4 | actor critical
MySql中的longtext字段的返回问题及解决
随机推荐
5 years of experience, 27 days of Android programmer interview, 2022 programmer advanced classic
[OBS] qstring's UTF-8 Chinese conversion to blog printing UTF-8 char*
Worthy of being a boss, byte Daniel spent eight months on another masterpiece
Is it safe for Guohai Securities to open an account online?
third-party dynamic library (libcudnn.so) that Paddle depends on is not configured correctl
力扣 729. 我的日程安排表 I
IBM has laid off 40 + year-old employees in a large area. Mastering these ten search skills will improve your work efficiency ten times
众昂矿业:2022年全球萤石行业市场供给现状分析
Explain in detail the functions and underlying implementation logic of the groups sets statement in SQL
Debezium系列之:修改源码支持unix_timestamp() as DEFAULT value
The relationship between temperature measurement and imaging accuracy of ifd-x micro infrared imager (module)
Reptile exercises (II)
建议收藏,我的腾讯Android面试经历分享
Common interview questions in Android, 2022 golden nine silver ten Android factory interview questions hit
redis集群模拟消息队列
Add data to excel small and medium-sized cases through poi
What does software testing do? What are the requirements for learning?
Webuploader file upload drag upload progress monitoring type control upload result monitoring control
third-party dynamic library (libcudnn.so) that Paddle depends on is not configured correctl
安信证券在网上开户安全吗?