📄 c_mlib.c
字号:
/* Ogle - A video player * Copyright (C) 2000, 2001 Martin Norb鋍k * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */#include <inttypes.h>#include "c_mlib.h"static inline voidmlib_VideoCopyRefAve_U8_U8 (uint8_t *curr_block, const uint8_t *ref_block, const int width, const int height, int32_t stride);static inline voidmlib_VideoInterpAveX_U8_U8(uint8_t *curr_block, const uint8_t *ref_block, const int width, int height, int32_t frame_stride, int32_t field_stride);static inline voidmlib_VideoInterpAveY_U8_U8(uint8_t *curr_block, const uint8_t *ref_block, const int width, const int height, int32_t frame_stride, int32_t field_stride);static inline voidmlib_VideoInterpAveXY_U8_U8(uint8_t *curr_block, const uint8_t *ref_block, const int width, const int height, int32_t frame_stride, int32_t field_stride);static inline voidmlib_VideoInterpX_U8_U8(uint8_t *curr_block, const uint8_t *ref_block, const int width, const int height, int32_t frame_stride, int32_t field_stride);static inline voidmlib_VideoInterpY_U8_U8(uint8_t *curr_block, const uint8_t *ref_block, const int width, const int height, int32_t frame_stride, int32_t field_stride);static inline voidmlib_VideoInterpXY_U8_U8(uint8_t *curr_block, const uint8_t *ref_block, const int width, const int height, int32_t frame_stride, int32_t field_stride);static inline unsigned intclip_to_u8 (int value){ //return value < 0 ? 0 : (value > 255 ? 255 : value); //return ((uint16_t)value) > 256 ? value < 0 ? 0 : 255 : value; return ((unsigned)value) > 256 ? ( 255 & ~(value >> 31) ) : value;}voidmlib_Init(void){}inline voidmlib_VideoCopyRef_U8_U8 (uint8_t *curr_block, const uint8_t *ref_block, const int32_t width, const int32_t height, int32_t stride){ int x, y; for (y = 0; y < height; y++) { for (x = 0; x < width; x++) curr_block[x] = ref_block[x]; ref_block += stride; curr_block += stride; }}static inline voidmlib_VideoCopyRefAve_U8_U8 (uint8_t *curr_block, const uint8_t *ref_block, const int width, const int height, int32_t stride){ int x, y; for (y = 0; y < height; y++) { for (x = 0; x < width; x++) curr_block[x] = (curr_block[x] + ref_block[x] + 1U) / 2U; ref_block += stride; curr_block += stride; }}static inline voidmlib_VideoInterpAveX_U8_U8(uint8_t *curr_block, const uint8_t *ref_block, const int width, const int height, int32_t frame_stride, int32_t field_stride) { int x, y; for (y = 0; y < height; y++) { for (x = 0; x < width; x++) curr_block[x] = (curr_block[x] + ((ref_block[x] + ref_block[x+1] + 1U) / 2U) + 1U) / 2U; ref_block += frame_stride; curr_block += frame_stride; }}static inline voidmlib_VideoInterpAveY_U8_U8(uint8_t *curr_block, const uint8_t *ref_block, const int width, const int height, int32_t frame_stride, int32_t field_stride) { int x, y; const uint8_t *ref_block_next = ref_block + field_stride; for (y = 0; y < height; y++) { for (x = 0; x < width; x++) curr_block[x] = (curr_block[x] + ((ref_block[x] + ref_block_next[x] + 1U) / 2U) + 1U) / 2U; curr_block += frame_stride; ref_block += frame_stride; ref_block_next += frame_stride; }}static inline voidmlib_VideoInterpAveXY_U8_U8(uint8_t *curr_block, const uint8_t *ref_block, const int width, const int height, int32_t frame_stride, int32_t field_stride) { int x, y; const uint8_t *ref_block_next = ref_block + field_stride; for (y = 0; y < height; y++) { for (x = 0; x < width; x++) curr_block[x] = (curr_block[x] + ((ref_block[x] + ref_block_next[x] + ref_block[x+1] + ref_block_next[x+1] + 2U) / 4U) + 1U) / 2U; curr_block += frame_stride; ref_block += frame_stride; ref_block_next += frame_stride; }}static inline voidmlib_VideoInterpX_U8_U8(uint8_t *curr_block, const uint8_t *ref_block, const int width, const int height, int32_t frame_stride, int32_t field_stride) { int x, y; for (y = 0; y < height; y++) { for (x = 0; x < width; x++) curr_block[x] = (ref_block[x] + ref_block[x+1] + 1U) / 2U; ref_block += frame_stride; curr_block += frame_stride; }}static inline voidmlib_VideoInterpY_U8_U8(uint8_t *curr_block, const uint8_t *ref_block, const int width, const int height, int32_t frame_stride, int32_t field_stride) { int x, y; const uint8_t *ref_block_next = ref_block + field_stride; for (y = 0; y < height; y++) { for (x = 0; x < width; x++) curr_block[x] = (ref_block[x] + ref_block_next[x] + 1U) / 2U; curr_block += frame_stride; ref_block += frame_stride; ref_block_next += frame_stride; }}static inline voidmlib_VideoInterpXY_U8_U8(uint8_t *curr_block, const uint8_t *ref_block, const int width, const int height, int32_t frame_stride, int32_t field_stride) { int x, y; const uint8_t *ref_block_next = ref_block + field_stride; for (y = 0; y < height; y++) { for (x = 0; x < width; x++) curr_block[x] = (ref_block[x] + ref_block_next[x] + ref_block[x+1] + ref_block_next[x+1] + 2U) / 4U; curr_block += frame_stride; ref_block += frame_stride; ref_block_next += frame_stride; }}voidmlib_VideoCopyRefAve_U8_U8_16x16(uint8_t *curr_block, const uint8_t *ref_block, int32_t stride){ mlib_VideoCopyRefAve_U8_U8 (curr_block, ref_block, 16, 16, stride);}void mlib_VideoCopyRefAve_U8_U8_16x8(uint8_t *curr_block, const uint8_t *ref_block, int32_t stride){ mlib_VideoCopyRefAve_U8_U8 (curr_block, ref_block, 16, 8, stride);}void mlib_VideoCopyRefAve_U8_U8_8x8(uint8_t *curr_block, const uint8_t *ref_block, int32_t stride){ mlib_VideoCopyRefAve_U8_U8 (curr_block, ref_block, 8, 8, stride);}void mlib_VideoCopyRefAve_U8_U8_8x4(uint8_t *curr_block, const uint8_t *ref_block, int32_t stride){ mlib_VideoCopyRefAve_U8_U8 (curr_block, ref_block, 8, 4, stride);}voidmlib_VideoCopyRef_U8_U8_16x16(uint8_t *curr_block, const uint8_t *ref_block, int32_t stride){ mlib_VideoCopyRef_U8_U8 (curr_block, ref_block, 16, 16, stride);}void mlib_VideoCopyRef_U8_U8_16x8(uint8_t *curr_block, const uint8_t *ref_block, int32_t stride){ mlib_VideoCopyRef_U8_U8 (curr_block, ref_block, 16, 8, stride);}void mlib_VideoCopyRef_U8_U8_8x8(uint8_t *curr_block, const uint8_t *ref_block, int32_t stride){ mlib_VideoCopyRef_U8_U8 (curr_block, ref_block, 8, 8, stride);}void mlib_VideoCopyRef_U8_U8_8x4(uint8_t *curr_block, const uint8_t *ref_block, int32_t stride){ mlib_VideoCopyRef_U8_U8 (curr_block, ref_block, 8, 4, stride);}voidmlib_VideoInterpAveX_U8_U8_16x16(uint8_t *curr_block, const uint8_t *ref_block, int32_t frame_stride, int32_t field_stride){ mlib_VideoInterpAveX_U8_U8 (curr_block, ref_block, 16, 16, frame_stride, field_stride);}void mlib_VideoInterpAveX_U8_U8_16x8(uint8_t *curr_block, const uint8_t *ref_block, int32_t frame_stride, int32_t field_stride){ mlib_VideoInterpAveX_U8_U8 (curr_block, ref_block, 16, 8, frame_stride, field_stride);}void mlib_VideoInterpAveX_U8_U8_8x8(uint8_t *curr_block, const uint8_t *ref_block, int32_t frame_stride, int32_t field_stride){ mlib_VideoInterpAveX_U8_U8 (curr_block, ref_block, 8, 8, frame_stride, field_stride);}void mlib_VideoInterpAveX_U8_U8_8x4(uint8_t *curr_block, const uint8_t *ref_block, int32_t frame_stride, int32_t field_stride){ mlib_VideoInterpAveX_U8_U8 (curr_block, ref_block, 8, 4, frame_stride, field_stride);}voidmlib_VideoInterpAveY_U8_U8_16x16(uint8_t *curr_block, const uint8_t *ref_block, int32_t frame_stride, int32_t field_stride){ mlib_VideoInterpAveY_U8_U8 (curr_block, ref_block, 16, 16, frame_stride, field_stride);}void mlib_VideoInterpAveY_U8_U8_16x8(uint8_t *curr_block, const uint8_t *ref_block, int32_t frame_stride, int32_t field_stride){ mlib_VideoInterpAveY_U8_U8 (curr_block, ref_block, 16, 8, frame_stride, field_stride);}void mlib_VideoInterpAveY_U8_U8_8x8(uint8_t *curr_block, const uint8_t *ref_block, int32_t frame_stride, int32_t field_stride){ mlib_VideoInterpAveY_U8_U8 (curr_block, ref_block, 8, 8, frame_stride, field_stride);}void mlib_VideoInterpAveY_U8_U8_8x4(uint8_t *curr_block, const uint8_t *ref_block, int32_t frame_stride, int32_t field_stride){ mlib_VideoInterpAveY_U8_U8 (curr_block, ref_block, 8, 4, frame_stride, field_stride);}voidmlib_VideoInterpAveXY_U8_U8_16x16(uint8_t *curr_block, const uint8_t *ref_block, int32_t frame_stride, int32_t field_stride){ mlib_VideoInterpAveXY_U8_U8 (curr_block, ref_block, 16, 16, frame_stride, field_stride);}void mlib_VideoInterpAveXY_U8_U8_16x8(uint8_t *curr_block, const uint8_t *ref_block, int32_t frame_stride, int32_t field_stride){ mlib_VideoInterpAveXY_U8_U8 (curr_block, ref_block, 16, 8, frame_stride, field_stride);}void mlib_VideoInterpAveXY_U8_U8_8x8(uint8_t *curr_block, const uint8_t *ref_block, int32_t frame_stride, int32_t field_stride){ mlib_VideoInterpAveXY_U8_U8 (curr_block, ref_block, 8, 8, frame_stride, field_stride);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -