mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-06 17:46:50 +08:00

1. Interface change: Separate normal config into three basic config and several runtime config: Three basic config - a. rate control config b. preprocess config c. video codec protocol config More flexible rate control interfaces are provided. More codec configure interfaces are provided. Change flag with bitmap is provided for further optimization. 2. Remove old codec config from controller and left rate control module only Encoder controller only handle user rate control requirement and bit allocation. Hal hardware encoder only handle qp calculation according given target bit. Remove all old codec code. 3. Move codec process to hal Different hardware will share same codec process function in common protocol directory. And different hardware api will register to same api set. Codec header generation is moved to separate hal directory. 4. Encoder will return length by task Encoder will NOT get stream information feedback from controller. All information required by encoder will be all stored in Task. 5. Add mpp_rc for rate control Move some common rate control utils to mpp_base. 6. Update mpi_enc_test and mpi_rc_test with new interface Change-Id: Iebb5e276a48f547167e1bed4673f21cc2f0c8ad5 Signed-off-by: Herman Chen <herman.chen@rock-chips.com> Signed-off-by: Lin Kesheng <lks@rock-chips.com>
190 lines
6.4 KiB
C
190 lines
6.4 KiB
C
/*
|
|
* Copyright 2015 Rockchip Electronics 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_COMMON_H__
|
|
#define __MPP_COMMON_H__
|
|
|
|
#include "rk_type.h"
|
|
|
|
#define MPP_TAG_SIZE 32
|
|
|
|
#define MPP_ABS(x) ((x) < (0) ? -(x) : (x))
|
|
|
|
#define MPP_MAX(a, b) ((a) > (b) ? (a) : (b))
|
|
#define MPP_MAX3(a, b, c) MPP_MAX(MPP_MAX(a,b),c)
|
|
#define MPP_MAX4(a, b, c, d) MPP_MAX((a), MPP_MAX3((b), (c), (d)))
|
|
|
|
#define MPP_MIN(a,b) ((a) > (b) ? (b) : (a))
|
|
#define MPP_MIN3(a,b,c) MPP_MIN(MPP_MIN(a,b),c)
|
|
#define MPP_MIN4(a, b, c, d) MPP_MIN((a), MPP_MIN3((b), (c), (d)))
|
|
|
|
#define MPP_SWAP(type, a, b) do {type SWAP_tmp = b; b = a; a = SWAP_tmp;} while(0)
|
|
#define MPP_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0]))
|
|
#define MPP_ALIGN(x, a) (((x)+(a)-1)&~((a)-1))
|
|
#define MPP_VSWAP(a, b) { a ^= b; b ^= a; a ^= b; }
|
|
|
|
#define MPP_RB16(x) ((((const RK_U8*)(x))[0] << 8) | ((const RK_U8*)(x))[1])
|
|
#define MPP_WB16(p, d) do { \
|
|
((RK_U8*)(p))[1] = (d); \
|
|
((RK_U8*)(p))[0] = (d)>>8; } while(0)
|
|
|
|
#define MPP_RL16(x) ((((const RK_U8*)(x))[1] << 8) | \
|
|
((const RK_U8*)(x))[0])
|
|
#define MPP_WL16(p, d) do { \
|
|
((RK_U8*)(p))[0] = (d); \
|
|
((RK_U8*)(p))[1] = (d)>>8; } while(0)
|
|
|
|
#define MPP_RB32(x) ((((const RK_U8*)(x))[0] << 24) | \
|
|
(((const RK_U8*)(x))[1] << 16) | \
|
|
(((const RK_U8*)(x))[2] << 8) | \
|
|
((const RK_U8*)(x))[3])
|
|
#define MPP_WB32(p, d) do { \
|
|
((RK_U8*)(p))[3] = (d); \
|
|
((RK_U8*)(p))[2] = (d)>>8; \
|
|
((RK_U8*)(p))[1] = (d)>>16; \
|
|
((RK_U8*)(p))[0] = (d)>>24; } while(0)
|
|
|
|
#define MPP_RL32(x) ((((const RK_U8*)(x))[3] << 24) | \
|
|
(((const RK_U8*)(x))[2] << 16) | \
|
|
(((const RK_U8*)(x))[1] << 8) | \
|
|
((const RK_U8*)(x))[0])
|
|
#define MPP_WL32(p, d) do { \
|
|
((RK_U8*)(p))[0] = (d); \
|
|
((RK_U8*)(p))[1] = (d)>>8; \
|
|
((RK_U8*)(p))[2] = (d)>>16; \
|
|
((RK_U8*)(p))[3] = (d)>>24; } while(0)
|
|
|
|
#define MPP_RB64(x) (((RK_U64)((const RK_U8*)(x))[0] << 56) | \
|
|
((RK_U64)((const RK_U8*)(x))[1] << 48) | \
|
|
((RK_U64)((const RK_U8*)(x))[2] << 40) | \
|
|
((RK_U64)((const RK_U8*)(x))[3] << 32) | \
|
|
((RK_U64)((const RK_U8*)(x))[4] << 24) | \
|
|
((RK_U64)((const RK_U8*)(x))[5] << 16) | \
|
|
((RK_U64)((const RK_U8*)(x))[6] << 8) | \
|
|
(RK_U64)((const RK_U8*)(x))[7])
|
|
#define MPP_WB64(p, d) do { \
|
|
((RK_U8*)(p))[7] = (d); \
|
|
((RK_U8*)(p))[6] = (d)>>8; \
|
|
((RK_U8*)(p))[5] = (d)>>16; \
|
|
((RK_U8*)(p))[4] = (d)>>24; \
|
|
((RK_U8*)(p))[3] = (d)>>32; \
|
|
((RK_U8*)(p))[2] = (d)>>40; \
|
|
((RK_U8*)(p))[1] = (d)>>48; \
|
|
((RK_U8*)(p))[0] = (d)>>56; } while(0)
|
|
|
|
#define MPP_RL64(x) (((RK_U64)((const RK_U8*)(x))[7] << 56) | \
|
|
((RK_U64)((const RK_U8*)(x))[6] << 48) | \
|
|
((RK_U64)((const RK_U8*)(x))[5] << 40) | \
|
|
((RK_U64)((const RK_U8*)(x))[4] << 32) | \
|
|
((RK_U64)((const RK_U8*)(x))[3] << 24) | \
|
|
((RK_U64)((const RK_U8*)(x))[2] << 16) | \
|
|
((RK_U64)((const RK_U8*)(x))[1] << 8) | \
|
|
(RK_U64)((const RK_U8*)(x))[0])
|
|
#define MPP_WL64(p, d) do { \
|
|
((RK_U8*)(p))[0] = (d); \
|
|
((RK_U8*)(p))[1] = (d)>>8; \
|
|
((RK_U8*)(p))[2] = (d)>>16; \
|
|
((RK_U8*)(p))[3] = (d)>>24; \
|
|
((RK_U8*)(p))[4] = (d)>>32; \
|
|
((RK_U8*)(p))[5] = (d)>>40; \
|
|
((RK_U8*)(p))[6] = (d)>>48; \
|
|
((RK_U8*)(p))[7] = (d)>>56; } while(0)
|
|
|
|
#define MPP_RB24(x) ((((const RK_U8*)(x))[0] << 16) | \
|
|
(((const RK_U8*)(x))[1] << 8) | \
|
|
((const RK_U8*)(x))[2])
|
|
#define MPP_WB24(p, d) do { \
|
|
((RK_U8*)(p))[2] = (d); \
|
|
((RK_U8*)(p))[1] = (d)>>8; \
|
|
((RK_U8*)(p))[0] = (d)>>16; } while(0)
|
|
|
|
#define MPP_RL24(x) ((((const RK_U8*)(x))[2] << 16) | \
|
|
(((const RK_U8*)(x))[1] << 8) | \
|
|
((const RK_U8*)(x))[0])
|
|
|
|
#define MPP_WL24(p, d) do { \
|
|
((RK_U8*)(p))[0] = (d); \
|
|
((RK_U8*)(p))[1] = (d)>>8; \
|
|
((RK_U8*)(p))[2] = (d)>>16; } while(0)
|
|
|
|
#include <stdio.h>
|
|
#if defined(_WIN32) && !defined(__MINGW32CE__)
|
|
#define snprintf _snprintf
|
|
#define fseeko _fseeki64
|
|
|
|
#include <direct.h>
|
|
#include <io.h>
|
|
#include <sys/stat.h>
|
|
#define chdir _chdir
|
|
#define mkdir _mkdir
|
|
#define access _access
|
|
#define off_t _off_t
|
|
|
|
#define R_OK 4 /* Test for read permission. */
|
|
#define W_OK 2 /* Test for write permission. */
|
|
#define X_OK 1 /* Test for execute permission. */
|
|
#define F_OK 0 /* Test for existence. */
|
|
|
|
#elif defined(__MINGW32CE__)
|
|
#define fseeko fseeko64
|
|
#else
|
|
#include <unistd.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/types.h>
|
|
#define mkdir(x) mkdir(x, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
|
|
#endif
|
|
|
|
|
|
#define __RETURN __Return
|
|
#define __FAILED __failed
|
|
|
|
#define ARG_T(t) t
|
|
#define ARG_N(a,b,c,d,N,...) N
|
|
#define ARG_N_HELPER(...) ARG_T(ARG_N(__VA_ARGS__))
|
|
#define COUNT_ARG(...) ARG_N_HELPER(__VA_ARGS__,4,3,2,1,0)
|
|
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
RK_S32 mpp_log2(RK_U32 v);
|
|
RK_S32 mpp_log2_16bit(RK_U32 v);
|
|
|
|
static __inline RK_S32 mpp_ceil_log2(RK_S32 x)
|
|
{
|
|
return mpp_log2((x - 1) << 1);
|
|
}
|
|
|
|
static __inline RK_S32 mpp_clip(RK_S32 a, RK_S32 amin, RK_S32 amax)
|
|
{
|
|
if (a < amin) return amin;
|
|
else if (a > amax) return amax;
|
|
else return a;
|
|
}
|
|
|
|
static __inline RK_U32 mpp_is_32bit()
|
|
{
|
|
return ((sizeof(void *) == 4) ? (1) : (0));
|
|
}
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /*__MPP_COMMON_H__*/
|
|
|