⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 04_a52dec.dpatch

📁 现在关于h.264的源码很多
💻 DPATCH
字号:
#! /bin/sh /usr/share/dpatch/dpatch-run## 01_configure.dpatch by Christian Marillat <marillat@debian.org>#### All lines beginning with ## DP:' are a description of the patch.## DP: Fix configure.@DPATCH@--- ffmpegcvs-20050716.orig/libavcodec/a52dec.c	2005-06-11 20:06:19.000000000 +0200+++ ffmpegcvs-20050716/libavcodec/a52dec.c	2005-06-11 20:06:40.000000000 +0200@@ -27,9 +27,45 @@  #ifdef CONFIG_A52BIN #include <dlfcn.h>-static const char* liba52name = "liba52.so.0";+static const char* liba52name = "liba52.so";++static int liba52_loaded = 0;+static int liba52_load_error = 0;++/*+ * virtual method table+ *+ * using this function table so the liba52 doesn't+ * have to be really linked together with ffmpeg+ * and might be linked in runtime - this allows binary+ * distribution of ffmpeg library which doens't depend+ * on liba52 library - but if user has it installed+ * it will be used - user might install such library+ * separately+ */+static void* liba52_handle;++static a52_state_t* (*a52_ptr_init)(uint32_t mm_accel);+#define a52_init (*a52_ptr_init)+static sample_t* (*a52_ptr_samples)(a52_state_t * state);+#define a52_samples (*a52_ptr_samples)+static int (*a52_ptr_syncinfo)(const uint8_t * buf, int * flags,+                      int * sample_rate, int * bit_rate);+#define a52_syncinfo (*a52_ptr_syncinfo)+static int (*a52_ptr_frame)(a52_state_t * state, uint8_t * buf, int * flags,+                   sample_t * level, sample_t bias);+#define a52_frame (*a52_ptr_frame)+//static void (*a52_ptr_dynrng)(a52_state_t * state,+//                     sample_t (* call) (sample_t, void *), void * data);+//#define a52_dynrng a52_ptr_dynrng+static int (*a52_ptr_block)(a52_state_t * state);+#define a52_block (*a52_ptr_block)+static void (*a52_ptr_free)(a52_state_t * state);+#define a52_free (*a52_ptr_free)+ #endif + /**  * liba52 - Copyright (C) Aaron Holtzman  * released under the GPL license.@@ -43,29 +79,6 @@     a52_state_t* state;     sample_t* samples; -    /*-     * virtual method table-     *-     * using this function table so the liba52 doesn't-     * have to be really linked together with ffmpeg-     * and might be linked in runtime - this allows binary-     * distribution of ffmpeg library which doens't depend-     * on liba52 library - but if user has it installed-     * it will be used - user might install such library-     * separately-     */-    void* handle;-    a52_state_t* (*a52_init)(uint32_t mm_accel);-    sample_t* (*a52_samples)(a52_state_t * state);-    int (*a52_syncinfo)(uint8_t * buf, int * flags,-			  int * sample_rate, int * bit_rate);-    int (*a52_frame)(a52_state_t * state, uint8_t * buf, int * flags,-		       sample_t * level, sample_t bias);-    void (*a52_dynrng)(a52_state_t * state,-			 sample_t (* call) (sample_t, void *), void * data);-    int (*a52_block)(a52_state_t * state);-    void (*a52_free)(a52_state_t * state);- } AC3DecodeState;  #ifdef CONFIG_A52BIN@@ -73,46 +86,104 @@ {     void* f = dlsym(handle, symbol);     if (!f)-	fprintf(stderr, "A52 Decoder - function '%s' can't be resolved\n", symbol);+        av_log(NULL, AV_LOG_ERROR, "A52 Decoder - function '%s' can't be resolved\n", symbol);     return f; }++static void unload_liba52(void);++/**+ * Check whether liba52 has been loaded. If not, returns a value < 0; zero else.+ * If not, loads the library.+ */+static int check_liba52_loaded(void)+{+    if (liba52_loaded)+        return 0;+        +    if (liba52_load_error)+        return -1;+    +    liba52_handle = dlopen(liba52name, RTLD_LAZY);+    if (!liba52_handle)+    {+        av_log(NULL, AV_LOG_ERROR, "A52 library %s could not be opened! \n%s\n", liba52name, dlerror());+        liba52_load_error = 1;+        return -1;+    }+  +    a52_ptr_init = (a52_state_t* (*)(uint32_t)) dlsymm(liba52_handle, "a52_init");+    a52_ptr_samples = (sample_t* (*)(a52_state_t*)) dlsymm(liba52_handle, "a52_samples");+    a52_ptr_syncinfo = (int (*)(const uint8_t*, int*, int*, int*)) dlsymm(liba52_handle, "a52_syncinfo");+    a52_ptr_frame = (int (*)(a52_state_t*, uint8_t*, int*, sample_t*, sample_t)) dlsymm(liba52_handle, "a52_frame");+    a52_ptr_block = (int (*)(a52_state_t*)) dlsymm(liba52_handle, "a52_block");+    a52_ptr_free = (void (*)(a52_state_t*)) dlsymm(liba52_handle, "a52_free");++    if(!a52_init || !a52_samples || !a52_syncinfo || !a52_frame || !a52_block || !a52_free)+    {+        unload_liba52();+        liba52_load_error = 1;+        return -1;+    }+    +    liba52_loaded = 1;+    +//    av_log(NULL, AV_LOG_INFO, "A52 library: Successfully loaded %s.\n", liba52name);+    +    return 0;+}++/** Unload the library, if loaded. */+static void unload_liba52(void)+{+    dlclose(liba52_handle);+    liba52_handle = 0;+    a52_ptr_init = 0;+    a52_ptr_samples = 0;+    a52_ptr_syncinfo = 0;+    a52_ptr_frame = 0;+    a52_ptr_block = 0;+    a52_ptr_free = 0;+    +//    av_log(NULL, AV_LOG_INFO, "A52 library: Unloaded %s.\n", liba52name);+    +    liba52_loaded = 0;+}+ #endif ++/* For external usage. Forward to a52_syncinfo. Needed for parser.c . */+int a52_syncinfo_ext(const uint8_t * buf, int * flags, int * sample_rate, int * bit_rate)+{+  int ret;+  +  ret = check_liba52_loaded();+  if(ret < 0)+  {+//    av_log(NULL, AV_LOG_ERROR, "A52 library: a52_syncinfo: Couldn't load library, error.\n");+    return 0;+  }++  return a52_syncinfo(buf, flags, sample_rate, bit_rate);+}+ static int a52_decode_init(AVCodecContext *avctx) {     AC3DecodeState *s = avctx->priv_data;+    int ret;  #ifdef CONFIG_A52BIN-    s->handle = dlopen(liba52name, RTLD_LAZY);-    if (!s->handle)+    ret = check_liba52_loaded();+    if(ret < 0)     {-	fprintf(stderr, "A52 library %s could not be opened! \n%s\n", liba52name, dlerror());+	av_log(avctx, AV_LOG_ERROR, "A52 library %s could not be opened! \n%s\n", liba52name, dlerror());         return -1;     }-    s->a52_init = (a52_state_t* (*)(uint32_t)) dlsymm(s->handle, "a52_init");-    s->a52_samples = (sample_t* (*)(a52_state_t*)) dlsymm(s->handle, "a52_samples");-    s->a52_syncinfo = (int (*)(uint8_t*, int*, int*, int*)) dlsymm(s->handle, "a52_syncinfo");-    s->a52_frame = (int (*)(a52_state_t*, uint8_t*, int*, sample_t*, sample_t)) dlsymm(s->handle, "a52_frame");-    s->a52_block = (int (*)(a52_state_t*)) dlsymm(s->handle, "a52_block");-    s->a52_free = (void (*)(a52_state_t*)) dlsymm(s->handle, "a52_free");-    if (!s->a52_init || !s->a52_samples || !s->a52_syncinfo-        || !s->a52_frame || !s->a52_block || !s->a52_free)-    {-	dlclose(s->handle);-        return -1;-    }-#else-    /* static linked version */-    s->handle = 0;-    s->a52_init = a52_init;-    s->a52_samples = a52_samples;-    s->a52_syncinfo = a52_syncinfo;-    s->a52_frame = a52_frame;-    s->a52_block = a52_block;-    s->a52_free = a52_free; #endif-    s->state = s->a52_init(0); /* later use CPU flags */-    s->samples = s->a52_samples(s->state);++    s->state = a52_init(0); /* later use CPU flags */+    s->samples = a52_samples(s->state);     s->inbuf_ptr = s->inbuf;     s->frame_size = 0; @@ -173,7 +244,7 @@             s->inbuf_ptr += len;             buf_size -= len;             if ((s->inbuf_ptr - s->inbuf) == HEADER_SIZE) {-                len = s->a52_syncinfo(s->inbuf, &s->flags, &sample_rate, &bit_rate);+                len = a52_syncinfo(s->inbuf, &s->flags, &sample_rate, &bit_rate);                 if (len == 0) {                     /* no sync found : move by one byte (inefficient, but simple!) */                     memcpy(s->inbuf, s->inbuf + 1, HEADER_SIZE - 1);@@ -213,14 +284,14 @@             else                 flags |= A52_ADJUST_LEVEL;             level = 1;-            if (s->a52_frame(s->state, s->inbuf, &flags, &level, 384)) {+            if (a52_frame(s->state, s->inbuf, &flags, &level, 384)) {             fail:                 s->inbuf_ptr = s->inbuf;                 s->frame_size = 0;                 continue;             }             for (i = 0; i < 6; i++) {-                if (s->a52_block(s->state))+                if (a52_block(s->state))                     goto fail;                 float_to_int(s->samples, out_samples + i * 256 * avctx->channels, avctx->channels);             }@@ -236,10 +307,12 @@ static int a52_decode_end(AVCodecContext *avctx) {     AC3DecodeState *s = avctx->priv_data;-    s->a52_free(s->state);+    a52_free(s->state);+ #ifdef CONFIG_A52BIN-    dlclose(s->handle);+    unload_liba52(); #endif+     return 0; } --- ffmpegcvs-20050716.orig/libavcodec/parser.c	2005-06-11 20:06:25.000000000 +0200+++ ffmpegcvs-20050716/libavcodec/parser.c	2005-06-11 20:06:40.000000000 +0200@@ -673,8 +673,8 @@ }  #ifdef CONFIG_AC3-extern int a52_syncinfo (const uint8_t * buf, int * flags,-                         int * sample_rate, int * bit_rate);+extern int a52_syncinfo_ext (const uint8_t * buf, int * flags,+                             int * sample_rate, int * bit_rate);  typedef struct AC3ParseContext {     uint8_t inbuf[4096]; /* input buffer */@@ -721,7 +721,7 @@             s->inbuf_ptr += len;             buf_size -= len;             if ((s->inbuf_ptr - s->inbuf) == AC3_HEADER_SIZE) {-                len = a52_syncinfo(s->inbuf, &s->flags, &sample_rate, &bit_rate);+                len = a52_syncinfo_ext(s->inbuf, &s->flags, &sample_rate, &bit_rate);                 if (len == 0) {                     /* no sync found : move by one byte (inefficient, but simple!) */                     memmove(s->inbuf, s->inbuf + 1, AC3_HEADER_SIZE - 1);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -