2 * huffyuv codec for libavcodec
4 * Copyright (c) 2002-2014 Michael Niedermayer <michaelni@gmx.at>
6 * see http://www.pcisys.net/~melanson/codecs/huffyuv.txt for a description of
9 * This file is part of FFmpeg.
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.
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.
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
28 * huffyuv codec for libavcodec.
33 #include "libavutil/mem.h"
39 int ff_huffyuv_generate_bits_table(uint32_t *dst
, const uint8_t *len_table
, int n
)
44 for (len
= 32; len
> 0; len
--) {
45 for (index
= 0; index
< n
; index
++) {
46 if (len_table
[index
] == len
)
50 av_log(NULL
, AV_LOG_ERROR
, "Error generating huffman table\n");
58 av_cold
int ff_huffyuv_alloc_temp(HYuvContext
*s
)
63 s
->temp
[i
]= av_malloc(4*s
->width
+ 16);
65 return AVERROR(ENOMEM
);
66 s
->temp16
[i
] = (uint16_t*)s
->temp
[i
];
71 av_cold
void ff_huffyuv_common_init(AVCodecContext
*avctx
)
73 HYuvContext
*s
= avctx
->priv_data
;
76 s
->flags
= avctx
->flags
;
78 ff_bswapdsp_init(&s
->bdsp
);
79 ff_llviddsp_init(&s
->llviddsp
, avctx
);
81 s
->width
= avctx
->width
;
82 s
->height
= avctx
->height
;
84 av_assert1(s
->width
> 0 && s
->height
> 0);
87 av_cold
void ff_huffyuv_common_end(HYuvContext
*s
)
91 for(i
= 0; i
< 3; i
++) {
92 av_freep(&s
->temp
[i
]);