Skip to content

Instantly share code, notes, and snippets.

@lu-zero
lu-zero / amf_dump.c
Last active December 23, 2015 13:39
In case you need it to debug flvdec.c
static void amf_dump(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
int v;
char buf[1024];
if (pb->eof_reached)
return;
switch ((v = avio_r8(pb))) {
static inline int get_ue_golomb(GetBitContext *gb)
{
unsigned int buf;
unsigned int re_index = (gb)->index;
unsigned int __attribute__((unused)) re_cache = 0;
unsigned int re_size_plus8 = (gb)->size_in_bits_plus8;
re_cache = av_bswap32((((const union unaligned_32 *)((gb)->buffer + (re_index >> 3)))->l)) << (re_index & 7);
buf = ((uint32_t)re_cache);
# prepare your environment
make distclean
mkdir .build-topic
cd .build-topic
../configure
make -j 8
# expand the file you are interested on
make libavcodec/h264_parser.i
uncrustify -c ~/uncrustify-libav.cfg libavcodec/h264_parser.i

now you can take the expanded macros from there and copy them in h264_parser.c and put as much logging as possible.

@lu-zero
lu-zero / bitstream-trace.h
Last active March 4, 2016 21:53 — forked from sasshka/gist:9fb9891ade4628145d3b
bitstream.h debugging
#define bistream_read_count(bb) ({\
int _ret = bitstream_read_count(bb); \
printf("%s:%d %s, read_count %d\n", __FILE__, __LINE__, __func__, _ret); \
_ret; \
})
#define bistream_read_bit(bb) ({\
int _ret = bitstream_read_bit(bb); \
printf("%s:%d %s, read_bit %d\n", __FILE__, __LINE__, __func__, _ret); \
_ret; \
@lu-zero
lu-zero / get_bits_debug.h
Last active March 5, 2016 19:53 — forked from anonymous/get_bits_debug.h
Tracing the old bitreader
#define get_bits_count(gb) \
({ \
int _ret = get_bits_count(gb); \
printf("%s:%d %s, read_count %d\n", __FILE__, __LINE__, __func__, _ret); \
_ret; \
})
#define get_bits1(gb) \
({ \
unsigned int _ret = get_bits1(gb); \
@lu-zero
lu-zero / per_slice_gb.diff
Last active March 14, 2016 12:47 — forked from anonymous/diff
diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
index 80bc46a..d651406 100644
--- a/libavcodec/svq3.c
+++ b/libavcodec/svq3.c
@@ -75,6 +75,7 @@ typedef struct SVQ3Context {
H264Picture *cur_pic;
H264Picture *next_pic;
H264Picture *last_pic;
+ GetBitContext slice;
int halfpel_flag;
--- /tmp/apedec.S 2016-04-13 07:07:23.000000000 +0200
+++ libavcodec/apedec.S 2016-04-13 07:08:39.000000000 +0200
@@ -47815,7 +47815,7 @@
.loc 18 1308 41 ## /Users/lu_zero/Sources/libav/libavcodec/apedec.c:1308:41
andl $-2147483648, %eax ## imm = 0xFFFFFFFF80000000
Ltmp4162:
- .loc 18 1308 56 is_stmt 0 ## /Users/lu_zero/Sources/libav/libavcodec/apedec.c:1308:56
+ .loc 18 1308 53 is_stmt 0 ## /Users/lu_zero/Sources/libav/libavcodec/apedec.c:1308:53
xorl $-1073741824, %eax ## imm = 0xFFFFFFFFC0000000
.loc 18 1309 55 is_stmt 1 ## /Users/lu_zero/Sources/libav/libavcodec/apedec.c:1309:55
diff --git a/libavcodec/mpegaudiodec_template.c b/libavcodec/mpegaudiodec_template.c
index 820a7ae..51a1943 100644
--- a/libavcodec/mpegaudiodec_template.c
+++ b/libavcodec/mpegaudiodec_template.c
@@ -33,6 +33,7 @@
#include "internal.h"
#include "mathops.h"
#include "mpegaudiodsp.h"
+#include "bitstream_debug.h"
@lu-zero
lu-zero / msdk-instructions.md
Last active April 25, 2016 12:00
msdk on windows
@lu-zero
lu-zero / prores
Created May 9, 2016 16:05
benchmark x86_32
fate .x86_32 # perf stat -r 30 ./avconv_old -v quiet -nostats -threads 1 -t 100 -i /tmp/test.mov -f null -
Performance counter stats for './avconv_old -v quiet -nostats -threads 1 -t 100 -i /tmp/test.mov -f null -' (30 runs):
33067.977078 task-clock (msec) # 0.999 CPUs utilized
2331 context-switches # 0.070 K/sec
13 cpu-migrations # 0.000 K/sec
8137 page-faults # 0.246 K/sec
125030253229 cycles # 3.778 GHz
25015097060 stalled-cycles-frontend # 20.02% frontend cycles idle