FFmpeg
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
libavcodec
huffyuv.c
Go to the documentation of this file.
1
/*
2
* huffyuv codec for libavcodec
3
*
4
* Copyright (c) 2002-2014 Michael Niedermayer <michaelni@gmx.at>
5
*
6
* see http://www.pcisys.net/~melanson/codecs/huffyuv.txt for a description of
7
* the algorithm used
8
*
9
* This file is part of FFmpeg.
10
*
11
* FFmpeg is free software; you can redistribute it and/or
12
* modify it under the terms of the GNU Lesser General Public
13
* License as published by the Free Software Foundation; either
14
* version 2.1 of the License, or (at your option) any later version.
15
*
16
* FFmpeg is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
* Lesser General Public License for more details.
20
*
21
* You should have received a copy of the GNU Lesser General Public
22
* License along with FFmpeg; if not, write to the Free Software
23
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24
*/
25
26
/**
27
* @file
28
* huffyuv codec for libavcodec.
29
*/
30
31
#include <stdint.h>
32
33
#include "
libavutil/mem.h
"
34
35
#include "
avcodec.h
"
36
#include "
bswapdsp.h
"
37
#include "
huffyuv.h
"
38
39
int
ff_huffyuv_generate_bits_table
(uint32_t *dst,
const
uint8_t
*len_table,
int
n
)
40
{
41
int
len
,
index
;
42
uint32_t
bits
= 0;
43
44
for
(len = 32; len > 0; len--) {
45
for
(index = 0; index <
n
; index++) {
46
if
(len_table[index] == len)
47
dst[
index
] = bits++;
48
}
49
if
(bits & 1) {
50
av_log
(
NULL
,
AV_LOG_ERROR
,
"Error generating huffman table\n"
);
51
return
-1;
52
}
53
bits >>= 1;
54
}
55
return
0;
56
}
57
58
av_cold
int
ff_huffyuv_alloc_temp
(
HYuvContext
*
s
)
59
{
60
int
i;
61
62
for
(i=0; i<3; i++) {
63
s->
temp
[i]=
av_malloc
(4*s->
width
+ 16);
64
if
(!s->
temp
[i])
65
return
AVERROR
(ENOMEM);
66
s->
temp16
[i] = (uint16_t*)s->
temp
[i];
67
}
68
return
0;
69
}
70
71
av_cold
void
ff_huffyuv_common_init
(
AVCodecContext
*avctx)
72
{
73
HYuvContext
*
s
= avctx->
priv_data
;
74
75
s->
avctx
= avctx;
76
s->
flags
= avctx->
flags
;
77
78
ff_bswapdsp_init
(&s->
bdsp
);
79
ff_llviddsp_init
(&s->
llviddsp
, avctx);
80
81
s->
width
= avctx->
width
;
82
s->
height
= avctx->
height
;
83
84
av_assert1
(s->
width
> 0 && s->
height
> 0);
85
}
86
87
av_cold
void
ff_huffyuv_common_end
(
HYuvContext
*
s
)
88
{
89
int
i;
90
91
for
(i = 0; i < 3; i++) {
92
av_freep
(&s->
temp
[i]);
93
s->
temp16
[i] =
NULL
;
94
}
95
}
NULL
#define NULL
Definition:
coverity.c:32
s
const char * s
Definition:
avisynth_c.h:631
mem.h
memory handling functions
HYuvContext::height
int height
Definition:
huffyuv.h:74
bits
uint8_t bits
Definition:
crc.c:295
uint8_t
uint8_t
Definition:
audio_convert.c:194
av_cold
#define av_cold
Definition:
attributes.h:74
av_malloc
#define av_malloc(s)
Definition:
tableprint_vlc.h:31
HYuvContext::temp16
uint16_t * temp16[3]
identical to temp but 16bit type
Definition:
huffyuv.h:80
av_log
#define av_log(a,...)
Definition:
tableprint_vlc.h:28
ff_huffyuv_alloc_temp
av_cold int ff_huffyuv_alloc_temp(HYuvContext *s)
Definition:
huffyuv.c:58
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition:
log.h:176
ff_huffyuv_common_end
av_cold void ff_huffyuv_common_end(HYuvContext *s)
Definition:
huffyuv.c:87
AVERROR
#define AVERROR(e)
Definition:
error.h:43
HYuvContext::flags
int flags
Definition:
huffyuv.h:75
AVCodecContext::flags
int flags
CODEC_FLAG_*.
Definition:
avcodec.h:1335
avcodec.h
Libavcodec external API header.
huffyuv.h
huffyuv codec for libavcodec.
ff_llviddsp_init
void ff_llviddsp_init(LLVidDSPContext *c, AVCodecContext *avctx)
Definition:
lossless_videodsp.c:118
ff_bswapdsp_init
av_cold void ff_bswapdsp_init(BswapDSPContext *c)
Definition:
bswapdsp.c:49
HYuvContext
Definition:
huffyuv.h:54
av_assert1
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition:
avassert.h:53
HYuvContext::width
int width
Definition:
huffyuv.h:74
AVCodecContext::width
int width
picture width / height.
Definition:
avcodec.h:1414
ff_huffyuv_generate_bits_table
int ff_huffyuv_generate_bits_table(uint32_t *dst, const uint8_t *len_table, int n)
Definition:
huffyuv.c:39
n
int n
Definition:
avisynth_c.h:547
HYuvContext::temp
uint8_t * temp[3]
Definition:
huffyuv.h:79
AVCodecContext::height
int height
Definition:
avcodec.h:1414
HYuvContext::llviddsp
LLVidDSPContext llviddsp
Definition:
huffyuv.h:91
AVCodecContext
main external API structure.
Definition:
avcodec.h:1241
index
int index
Definition:
gxfenc.c:89
HYuvContext::avctx
AVCodecContext * avctx
Definition:
huffyuv.h:56
ff_huffyuv_common_init
av_cold void ff_huffyuv_common_init(AVCodecContext *avctx)
Definition:
huffyuv.c:71
AVCodecContext::priv_data
void * priv_data
Definition:
avcodec.h:1283
len
int len
Definition:
vorbis_enc_data.h:452
bswapdsp.h
av_freep
#define av_freep(p)
Definition:
tableprint_vlc.h:35
HYuvContext::bdsp
BswapDSPContext bdsp
Definition:
huffyuv.h:88
Generated on Wed Jun 10 2015 01:56:42 for FFmpeg by
1.8.6