当前位置:网站首页>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;
}
}
边栏推荐
- C#应用程序界面开发基础——窗体控制(6)——菜单栏、工具栏和状态栏控件
- Common - Hero Minesweeper
- Debezium系列之:修改源码支持unix_timestamp() as DEFAULT value
- IBM大面积辞退40岁+的员工,掌握这十个搜索技巧让你的工作效率至上提高十倍
- MySql中的longtext字段的返回问题及解决
- Common interview questions in Android, 2022 golden nine silver ten Android factory interview questions hit
- gst-launch的-v参数
- 【FAQ】华为帐号服务报错 907135701的常见原因总结和解决方法
- 【硬核干货】数据分析哪家强?选Pandas还是选SQL
- Two pits exported using easyexcel template (map empty data columns are disordered and nested objects are not supported)
猜你喜欢
JAD installation, configuration and integration idea
PHP uses ueditor to upload pictures and add watermarks
Hiengine: comparable to the local cloud native memory database engine
What are the reliable domestic low code development platforms?
What does software testing do? What are the requirements for learning?
JAD的安装、配置及集成IDEA
40000 word Wenshuo operator new & operator delete
Microwave radar induction module technology, real-time intelligent detection of human existence, static micro motion and static perception
Decision tree and random forest
Can Leica capture the high-end market offered by Huawei for Xiaomi 12s?
随机推荐
That's awesome. It's enough to read this article
C application interface development foundation - form control (5) - grouping control
Is it safe for China Galaxy Securities to open an account? Securities account opening
国海证券在网上开户安全吗?
third-party dynamic library (libcudnn.so) that Paddle depends on is not configured correctl
Information / data
【FAQ】华为帐号服务报错 907135701的常见原因总结和解决方法
建议收藏,我的腾讯Android面试经历分享
多分支结构
The binary string mode is displayed after the value with the field type of longtext in MySQL is exported
vagrant2.2.6支持virtualbox6.1版本
Zhongang Mining: analysis of the current market supply situation of the global fluorite industry in 2022
Shell编程基础(第8篇:分支语句-case in)
完爆面试官,一线互联网企业高级Android工程师面试题大全
Django使用mysqlclient服务连接并写入数据库的操作过程
How to convert word into PDF? Word to PDF simple way to share!
力扣 1200. 最小绝对差
40000 word Wenshuo operator new & operator delete
安信证券在网上开户安全吗?
手机股票开户安全吗?靠不靠谱啊?