mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-05 17:16:50 +08:00
add temp value in READ_BITS ect macro define
git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@343 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
@@ -1,18 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2015 Rockchip Electronics Co. LTD
|
* Copyright 2015 Rockchip Electronics Co. LTD
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
#ifndef __MPP_BITREAD_H__
|
#ifndef __MPP_BITREAD_H__
|
||||||
#define __MPP_BITREAD_H__
|
#define __MPP_BITREAD_H__
|
||||||
@@ -24,55 +24,63 @@
|
|||||||
#include "mpp_common.h"
|
#include "mpp_common.h"
|
||||||
#include "mpp_err.h"
|
#include "mpp_err.h"
|
||||||
|
|
||||||
#define __BITREAD_ERR __bitread_error
|
#define __BITREAD_ERR __bitread_error
|
||||||
typedef void (*LOG_FUN)(void *ctx, ...);
|
typedef void (*LOG_FUN)(void *ctx, ...);
|
||||||
|
|
||||||
#define BitReadLog(bitctx, ...)\
|
#define BitReadLog(bitctx, ...)\
|
||||||
do {\
|
do {\
|
||||||
bitctx->wlog(bitctx->ctx, __FILE__, __LINE__, ##__VA_ARGS__);\
|
bitctx->wlog(bitctx->ctx, __FILE__, __LINE__, ##__VA_ARGS__);\
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
#define READ_BITS(bitctx, num_bits, out, ...) \
|
#define READ_BITS(bitctx, num_bits, out, ...)\
|
||||||
do {\
|
do {\
|
||||||
bitctx->ret = mpp_read_bits(bitctx, num_bits, (RK_S32 *)out); \
|
RK_S32 _out;\
|
||||||
BitReadLog(bitctx, "%48s = %10d", ##__VA_ARGS__, *out); \
|
bitctx->ret = mpp_read_bits(bitctx, num_bits, &_out);\
|
||||||
if (bitctx->ret) { mpp_assert(0); goto __BITREAD_ERR; } \
|
BitReadLog(bitctx, "%48s = %10d", ##__VA_ARGS__, _out); \
|
||||||
} while (0)
|
if (!bitctx->ret) { *out = _out; }\
|
||||||
|
else { mpp_assert(0); goto __BITREAD_ERR;}\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
#define SKIP_BITS(bitctx, num_bits)\
|
#define SKIP_BITS(bitctx, num_bits)\
|
||||||
do {\
|
do {\
|
||||||
bitctx->ret = mpp_skip_bits(bitctx, num_bits);\
|
bitctx->ret = mpp_skip_bits(bitctx, num_bits);\
|
||||||
BitReadLog(bitctx, "%48s", "skip");\
|
BitReadLog(bitctx, "%48s", "skip");\
|
||||||
if (bitctx->ret) { mpp_assert(0); goto __BITREAD_ERR; }\
|
if (bitctx->ret) { mpp_assert(0); goto __BITREAD_ERR; }\
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define READ_ONEBIT(bitctx, out, ...)\
|
#define READ_ONEBIT(bitctx, out, ...)\
|
||||||
do {\
|
do {\
|
||||||
bitctx->ret = mpp_read_bits(bitctx, 1, (RK_S32 *)out);\
|
RK_S32 _out;\
|
||||||
BitReadLog(bitctx, "%48s = %10d", ##__VA_ARGS__, *out);\
|
bitctx->ret = mpp_read_bits(bitctx, 1, &_out);\
|
||||||
if (bitctx->ret) { mpp_assert(0); goto __BITREAD_ERR; }\
|
BitReadLog(bitctx, "%48s = %10d", ##__VA_ARGS__, _out);\
|
||||||
} while (0)
|
if (!bitctx->ret) { *out = _out; }\
|
||||||
|
else { mpp_assert(0); goto __BITREAD_ERR;}\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define READ_UE(bitctx, out, ...)\
|
#define READ_UE(bitctx, out, ...)\
|
||||||
do {\
|
do {\
|
||||||
bitctx->ret = mpp_read_ue(bitctx, (RK_U32 *)out);\
|
RK_U32 _out;\
|
||||||
BitReadLog(bitctx, "%48s = %10d", ##__VA_ARGS__, *out);\
|
bitctx->ret = mpp_read_ue(bitctx, &_out);\
|
||||||
if (bitctx->ret) { mpp_assert(0); goto __BITREAD_ERR; }\
|
BitReadLog(bitctx, "%48s = %10d", ##__VA_ARGS__, _out);\
|
||||||
} while (0)
|
if (!bitctx->ret) { *out = _out; }\
|
||||||
|
else { mpp_assert(0); goto __BITREAD_ERR;}\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define READ_SE(bitctx, out, ...)\
|
#define READ_SE(bitctx, out, ...)\
|
||||||
do {\
|
do {\
|
||||||
bitctx->ret = mpp_read_se(bitctx, (RK_S32 *)out);\
|
RK_S32 _out;\
|
||||||
BitReadLog(bitctx, "%48s = %10d", ##__VA_ARGS__, *out);\
|
bitctx->ret = mpp_read_se(bitctx, &_out);\
|
||||||
if (bitctx->ret) { mpp_assert(0); goto __BITREAD_ERR; }\
|
BitReadLog(bitctx, "%48s = %10d", ##__VA_ARGS__, _out);\
|
||||||
} while (0)
|
if (!bitctx->ret) { *out = _out; }\
|
||||||
|
else { mpp_assert(0); goto __BITREAD_ERR;}\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
typedef struct bitread_ctx_t{
|
typedef struct bitread_ctx_t {
|
||||||
// Pointer to the next unread (not in curr_byte_) byte in the stream.
|
// Pointer to the next unread (not in curr_byte_) byte in the stream.
|
||||||
RK_U8 *data_;
|
RK_U8 *data_;
|
||||||
// Bytes left in the stream (without the curr_byte_).
|
// Bytes left in the stream (without the curr_byte_).
|
||||||
@@ -92,10 +100,10 @@ typedef struct bitread_ctx_t{
|
|||||||
RK_S32 used_bits;
|
RK_S32 used_bits;
|
||||||
RK_U8 *buf;
|
RK_U8 *buf;
|
||||||
RK_S32 buf_len;
|
RK_S32 buf_len;
|
||||||
// ctx
|
// ctx
|
||||||
MPP_RET ret;
|
MPP_RET ret;
|
||||||
void *ctx;
|
void *ctx;
|
||||||
LOG_FUN wlog;
|
LOG_FUN wlog;
|
||||||
} BitReadCtx_t;
|
} BitReadCtx_t;
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user