mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-04 16:52:40 +08:00
[utils]: add mpp_frame write file function to utils
git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@921 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
@@ -25,8 +25,52 @@ void _show_options(int count, OptionInfo *options)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < count; i++) {
|
||||
mpp_log("-%s %s\t\t%s\n",
|
||||
mpp_log("-%s %-16s\t%s\n",
|
||||
options[i].name, options[i].argname, options[i].help);
|
||||
}
|
||||
}
|
||||
|
||||
void dump_mpp_frame_to_file(MppFrame frame, FILE *fp)
|
||||
{
|
||||
RK_U32 width = 0;
|
||||
RK_U32 height = 0;
|
||||
RK_U32 h_stride = 0;
|
||||
RK_U32 v_stride = 0;
|
||||
MppFrameFormat fmt = MPP_FMT_YUV420SP;
|
||||
MppBuffer buffer = NULL;
|
||||
RK_U8 *base = NULL;
|
||||
|
||||
if (NULL == fp || NULL == frame)
|
||||
return ;
|
||||
|
||||
width = mpp_frame_get_width(frame);
|
||||
height = mpp_frame_get_height(frame);
|
||||
h_stride = mpp_frame_get_hor_stride(frame);
|
||||
v_stride = mpp_frame_get_ver_stride(frame);
|
||||
fmt = mpp_frame_get_fmt(frame);
|
||||
buffer = mpp_frame_get_buffer(frame);
|
||||
|
||||
if (NULL == buffer)
|
||||
return ;
|
||||
|
||||
base = (RK_U8 *)mpp_buffer_get_ptr(buffer);
|
||||
|
||||
switch (fmt) {
|
||||
case MPP_FMT_YUV420SP : {
|
||||
RK_U32 i;
|
||||
RK_U8 *base_y = base;
|
||||
RK_U8 *base_c = base + h_stride * v_stride;
|
||||
|
||||
for (i = 0; i < height; i++, base_y += h_stride) {
|
||||
fwrite(base_y, 1, width, fp);
|
||||
}
|
||||
for (i = 0; i < height / 2; i++, base_c += h_stride) {
|
||||
fwrite(base_c, 1, width, fp);
|
||||
}
|
||||
} break;
|
||||
default : {
|
||||
mpp_err("not supported format %d\n", fmt);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -17,6 +17,9 @@
|
||||
#ifndef __UTILS_H__
|
||||
#define __UTILS_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include "mpp_frame.h"
|
||||
|
||||
typedef struct OptionInfo_t {
|
||||
const char* name;
|
||||
const char* argname;
|
||||
@@ -33,6 +36,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
void _show_options(int count, OptionInfo *options);
|
||||
void dump_mpp_frame_to_file(MppFrame frame, FILE *fp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Reference in New Issue
Block a user