MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / old_codec45

Function old_codec45

libavcodec/sanm.c:1957–2015  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1955}
1956
1957static void old_codec45(SANMVideoContext *ctx, GetByteContext *gb, int top, int left, int flag)
1958{
1959 int t1, t2, i;
1960
1961 if (bytestream2_get_bytes_left(gb) < 6)
1962 return;
1963
1964 bytestream2_skip(gb, 2);
1965 t1 = bytestream2_get_le16u(gb);
1966 t2 = bytestream2_get_byteu(gb);
1967 bytestream2_skip(gb, 1);
1968 if (t2 != 1)
1969 return;
1970 if (t1 == 0) {
1971 if (bytestream2_get_bytes_left(gb) < 0x300)
1972 return;
1973 bytestream2_get_bufferu(gb, ctx->c45tbl1, 0x300);
1974 i = 0;
1975 while ((bytestream2_get_bytes_left(gb) > 1) && (i < 0x8000)) {
1976 uint8_t len = bytestream2_get_byteu(gb);
1977 uint8_t val = bytestream2_get_byteu(gb);
1978 if ((i + len) > 0x8000)
1979 len = 0x8000 - i;
1980 memset(ctx->c45tbl2 + i, val, len);
1981 i += len;
1982 }
1983 }
1984
1985 if (flag)
1986 return;
1987
1988 while (bytestream2_get_bytes_left(gb) > 3) {
1989 left += (int16_t)bytestream2_get_le16u(gb);
1990 top += bytestream2_get_byteu(gb);
1991 int len = bytestream2_get_byteu(gb);
1992 while (len >= 0) {
1993 if ((left > 0) && (top > 0) && (left < (ctx->width - 1))) {
1994 if (top >= (ctx->height - 1))
1995 return;
1996
1997 uint8_t *dst = (uint8_t *)ctx->fbuf + left + top * ctx->pitch;
1998 unsigned int c1 = *(dst - 1) * 3;
1999 unsigned int c2 = *(dst + 1) * 3;
2000 unsigned int r = ctx->c45tbl1[c1 + 0] + ctx->c45tbl1[c2 + 0];
2001 unsigned int g = ctx->c45tbl1[c1 + 1] + ctx->c45tbl1[c2 + 1];
2002 unsigned int b = ctx->c45tbl1[c1 + 2] + ctx->c45tbl1[c2 + 2];
2003 c1 = *(dst - ctx->pitch) * 3;
2004 c2 = *(dst + ctx->pitch) * 3;
2005 r += ctx->c45tbl1[c1 + 0] + ctx->c45tbl1[c2 + 0];
2006 g += ctx->c45tbl1[c1 + 1] + ctx->c45tbl1[c2 + 1];
2007 b += ctx->c45tbl1[c1 + 2] + ctx->c45tbl1[c2 + 2];
2008 *dst = ctx->c45tbl2[((r << 5) & 0x7c00) | (g & 0x3e0) | (b >> 5)];
2009 }
2010 left++;
2011 len--;
2012 }
2013 left--;
2014 }

Callers 1

process_frame_objFunction · 0.85

Calls 3

bytestream2_skipFunction · 0.85
bytestream2_get_bufferuFunction · 0.85

Tested by

no test coverage detected