1 /* 2 * include/linux/amlogic/media/codec_mm/configs.h 3 * 4 * Copyright (C) 2017 Amlogic, Inc. All rights reserved. 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14 * more details. 15 * 16 */ 17 18 #ifndef UTILS_COMMON_H 19 #define UTILS_COMMON_H 20 21 #include "pixfmt.h" 22 23 #define AV_INPUT_BUFFER_PADDING_SIZE 64 24 #define MIN_CACHE_BITS 64 25 26 #define FFMAX(a,b) ((a) > (b) ? (a) : (b)) 27 #define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c) 28 #define FFMIN(a,b) ((a) > (b) ? (b) : (a)) 29 #define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c) 30 31 #define AV_WL32(p, val) \ 32 do { \ 33 u32 d = (val); \ 34 ((u8*)(p))[0] = (d); \ 35 ((u8*)(p))[1] = (d) >> 8; \ 36 ((u8*)(p))[2] = (d) >> 16; \ 37 ((u8*)(p))[3] = (d) >> 24; \ 38 } while(0) 39 40 #define AV_WB32(p, val) \ 41 do { u32 d = (val); \ 42 ((u8*)(p))[3] = (d); \ 43 ((u8*)(p))[2] = (d) >> 8; \ 44 ((u8*)(p))[1] = (d) >> 16; \ 45 ((u8*)(p))[0] = (d) >> 24; \ 46 } while(0) 47 48 #define AV_RB32(x) \ 49 (((u32)((const u8*)(x))[0] << 24) | \ 50 (((const u8*)(x))[1] << 16) | \ 51 (((const u8*)(x))[2] << 8) | \ 52 ((const u8*)(x))[3]) 53 54 #define AV_RL32(x) \ 55 (((u32)((const u8*)(x))[3] << 24) | \ 56 (((const u8*)(x))[2] << 16) | \ 57 (((const u8*)(x))[1] << 8) | \ 58 ((const u8*)(x))[0]) 59 60 #define NEG_SSR32(a, s) (((int)(a)) >> ((s < 32) ? (32 - (s)) : 0)) 61 #define NEG_USR32(a, s) (((u32)(a)) >> ((s < 32) ? (32 - (s)) : 0)) 62 63 //rounded division & shift 64 #define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b)) 65 /* assume b>0 */ 66 #define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b)) 67 68 struct AVRational{ 69 int num; ///< numerator 70 int den; ///< denominator 71 }; 72 73 //fmt 74 const char *av_color_space_name(enum AVColorSpace space); 75 const char *av_color_primaries_name(enum AVColorPrimaries primaries); 76 const char *av_color_transfer_name(enum AVColorTransferCharacteristic transfer); 77 78 //math 79 int av_log2(u32 v); 80 81 //bitstream 82 int find_start_code(u8 *data, int data_sz); 83 int calc_nal_len(u8 *data, int len); 84 u8 *nal_unit_extract_rbsp(const u8 *src, u32 src_len, u32 *dst_len); 85 86 //debug 87 void print_hex_debug(u8 *data, u32 len, int max); 88 89 #endif