[mpp_frame]: add mpp_frame implement

git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@149 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
ChenHengming 2015-08-21 10:56:46 +00:00
parent e4b70ac8d3
commit bd72588e8f
4 changed files with 148 additions and 0 deletions

View File

@ -24,6 +24,7 @@ add_library(mpp STATIC
mpp_buffer_impl.cpp
mpp_buffer.cpp
mpp_packet.cpp
mpp_frame.cpp
mpi_impl.cpp
mpi.cpp
)

View File

@ -58,6 +58,7 @@ MPP_RET mpp_buffer_get_with_tag(const char *tag, MppBufferGroup group, MppBuffer
NULL,
NULL,
-1,
NULL,
};
// if failed try init a new buffer
mpp_buffer_create(tag, tmp->group_id, &info);

66
mpp/mpp_frame.cpp Normal file
View File

@ -0,0 +1,66 @@
/*
* Copyright 2010 Rockchip Electronics S.LSI Co. LTD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define MODULE_TAG "mpp_frame"
#include "mpp_log.h"
#include "mpp_mem.h"
#include "mpp_frame_impl.h"
MPP_FRAME_ACCESSORS(MppFrameImpl, RK_U32, width)
MPP_FRAME_ACCESSORS(MppFrameImpl, RK_U32, height)
MPP_FRAME_ACCESSORS(MppFrameImpl, RK_U32, hor_stride)
MPP_FRAME_ACCESSORS(MppFrameImpl, RK_U32, ver_stride)
MPP_FRAME_ACCESSORS(MppFrameImpl, RK_U32, mode)
MPP_FRAME_ACCESSORS(MppFrameImpl, RK_S64, pts)
MPP_FRAME_ACCESSORS(MppFrameImpl, RK_S64, dts)
MPP_FRAME_ACCESSORS(MppFrameImpl, MppFrameColorRange, color_range)
MPP_FRAME_ACCESSORS(MppFrameImpl, MppFrameColorPrimaries, color_primaries)
MPP_FRAME_ACCESSORS(MppFrameImpl, MppFrameColorTransferCharacteristic, color_trc)
MPP_FRAME_ACCESSORS(MppFrameImpl, MppFrameColorSpace, colorspace)
MPP_FRAME_ACCESSORS(MppFrameImpl, MppFrameChromaLocation, chroma_location)
MPP_FRAME_ACCESSORS(MppFrameImpl, MppBufferInfo, buffer)
MPP_RET mpp_frame_init(MppFrame *frame)
{
if (NULL == frame) {
mpp_err("mpp_frame_init invalid NULL pointer input\n");
return MPP_ERR_NULL_PTR;
}
MppFrameImpl *p = mpp_calloc(MppFrameImpl, 1);
if (NULL == p) {
mpp_err("mpp_frame_init malloc failed\n");
return MPP_ERR_NULL_PTR;
}
*frame = p;
return MPP_OK;
}
MPP_RET mpp_frame_deinit(MppFrame frame)
{
if (NULL == frame) {
mpp_err("mpp_frame_deinit invalid NULL pointer input\n");
return MPP_ERR_NULL_PTR;
}
mpp_free(frame);
return MPP_OK;
}

80
mpp/mpp_frame_impl.h Normal file
View File

@ -0,0 +1,80 @@
/*
* Copyright 2010 Rockchip Electronics S.LSI Co. LTD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __MPP_FRAME_IMPL_H__
#define __MPP_FRAME_IMPL_H__
#include "mpp_frame.h"
typedef struct {
/*
* dimension parameter for display
*/
RK_U32 width;
RK_U32 height;
RK_U32 hor_stride;
RK_U32 ver_stride;
/*
* interlaced related mode status
*
* 0 - frame
* 1 - top field
* 2 - bottom field
* 3 - paired top and bottom field
* 4 - deinterlaced flag
* 7 - deinterlaced paired field
*/
RK_U32 mode;
/*
* pts - display time stamp
* dts - decode time stamp
*/
RK_S64 pts;
RK_S64 dts;
MppFrameColorRange color_range;
MppFrameColorPrimaries color_primaries;
MppFrameColorTransferCharacteristic color_trc;
/**
* YUV colorspace type.
* It must be accessed using av_frame_get_colorspace() and
* av_frame_set_colorspace().
* - encoding: Set by user
* - decoding: Set by libavcodec
*/
MppFrameColorSpace colorspace;
MppFrameChromaLocation chroma_location;
/*
* buffer information
*/
MppBufferInfo buffer;
} MppFrameImpl;
/*
* object access function macro
*/
#define MPP_FRAME_ACCESSORS(impl, type, field) \
type mpp_frame_get_##field(const MppFrame *s) { return ((impl*)s)->field; } \
void mpp_frame_set_##field(MppFrame *s, type v) { ((impl*)s)->field = v; }
#endif /*__MPP_FRAME_IMPL_H__*/