History

avcodec/huffman: Use logcontext instead of AVCodecContext

Said AVCodecContext is only used for logging; it furthermore avoids an avcodec.h inclusion.

Andreas Rheinhardt committed 5 years ago

Commit b75dc8b1 parent a449fb32 files · +6 −6Browse files

Unified · Split

2 files
  1. libavcodec/huffman.c +3 −4
  2. libavcodec/huffman.h +3 −2
libavcodec/huffman.c+3−4
@@ -29,7 +29,6 @@ · 28 unmodified lines
29#include "libavutil/qsort.h"29#include "libavutil/qsort.h"
30#include "libavutil/common.h"30#include "libavutil/common.h"
31 31
32#include "avcodec.h"
33#include "huffman.h"32#include "huffman.h"
34#include "vlc.h"33#include "vlc.h"
35 34
@@ -154,7 +153,7 @@ static int build_huff_tree(VLC *vlc, Node *nodes, int head, int flags, int nb_bi · 118 unmodified lines
154 * nodes size must be 2*nb_codes153 * nodes size must be 2*nb_codes
155 * first nb_codes nodes.count must be set154 * first nb_codes nodes.count must be set
156 */155 */
157int ff_huff_build_tree(AVCodecContext *avctx, VLC *vlc, int nb_codes, int nb_bits,156int ff_huff_build_tree(void *logctx, VLC *vlc, int nb_codes, int nb_bits,
158 Node *nodes, HuffCmp cmp, int flags)157 Node *nodes, HuffCmp cmp, int flags)
159{158{
160 int i, j;159 int i, j;
@@ -168,7 +167,7 @@ int ff_huff_build_tree(AVCodecContext *avctx, VLC *vlc, int nb_codes, int nb_bit · 7 unmodified lines
168 }167 }
169 168
170 if (sum >> 31) {169 if (sum >> 31) {
171 av_log(avctx, AV_LOG_ERROR,170 av_log(logctx, AV_LOG_ERROR,
172 "Too high symbol frequencies. "171 "Too high symbol frequencies. "
173 "Tree construction is not possible\n");172 "Tree construction is not possible\n");
174 return -1;173 return -1;
@@ -193,7 +192,7 @@ int ff_huff_build_tree(AVCodecContext *avctx, VLC *vlc, int nb_codes, int nb_bit · 18 unmodified lines
193 cur_node++;192 cur_node++;
194 }193 }
195 if (build_huff_tree(vlc, nodes, nb_codes * 2 - 2, flags, nb_bits) < 0) {194 if (build_huff_tree(vlc, nodes, nb_codes * 2 - 2, flags, nb_bits) < 0) {
196 av_log(avctx, AV_LOG_ERROR, "Error building tree\n");195 av_log(logctx, AV_LOG_ERROR, "Error building tree\n");
197 return -1;196 return -1;
198 }197 }
199 return 0;198 return 0;
libavcodec/huffman.h+3−2
@@ -26,7 +26,8 @@ · 25 unmodified lines
26#ifndef AVCODEC_HUFFMAN_H26#ifndef AVCODEC_HUFFMAN_H
27#define AVCODEC_HUFFMAN_H27#define AVCODEC_HUFFMAN_H
28 28
29#include "avcodec.h"29#include <stdint.h>
30
30#include "vlc.h"31#include "vlc.h"
31 32
32typedef struct Node {33typedef struct Node {
@@ -40,7 +41,7 @@ typedef struct Node { · 7 unmodified lines
40#define FF_HUFFMAN_BITS 1041#define FF_HUFFMAN_BITS 10
41 42
42typedef int (*HuffCmp)(const void *va, const void *vb);43typedef int (*HuffCmp)(const void *va, const void *vb);
43int ff_huff_build_tree(AVCodecContext *avctx, VLC *vlc, int nb_codes, int nb_bits,44int ff_huff_build_tree(void *logctx, VLC *vlc, int nb_codes, int nb_bits,
44 Node *nodes, HuffCmp cmp, int flags);45 Node *nodes, HuffCmp cmp, int flags);
45 46
46int ff_huff_gen_len_table(uint8_t *dst, const uint64_t *stats, int n, int skip0);47int ff_huff_gen_len_table(uint8_t *dst, const uint64_t *stats, int n, int skip0);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t