mirror of
https://github.com/xenia-project/FFmpeg.git
synced 2024-11-24 12:09:55 +00:00
d66c52c2b3
This requires the makedef perl script by Derek, from the c89-to-c99 repo. That scripts produces a .def file, listing the symbols to be exported, based on the gcc version scripts and the built object files. To properly load non-function symbols from DLL files, the data symbol declarations need to have the attribute __declspec(dllimport) when building the calling code. (On mingw, the linker can fix this up automatically, which is why it has not been an issue so far. If this attribute is omitted, linking actually succeeds, but reads from the table will not produce the desired results at runtime.) MSVC seems to manage to link DLLs (and run properly) even if this attribute is present while building the library itself (which normally isn't recommended) - other object files in the same library manage to link to the symbol (with a small warning at link time, like "warning LNK4049: locally defined symbol _avpriv_mpa_bitrate_tab imported" - it doesn't seem to be possible to squelch this warning), and the definition of the tables themselves produce a warning that can be squelched ("warning C4273: 'avpriv_mpa_bitrate_tab' : inconsistent dll linkage, see previous definition of 'avpriv_mpa_bitrate_tab'). In this setup, mingw isn't able to link object files that refer to data symbols with __declspec(dllimport) without those symbols actually being linked via a DLL (linking avcodec.dll ends up with errors like "undefined reference to `__imp__avpriv_mpa_freq_tab'"). The dllimport declspec isn't needed at all in mingw, so we simply choose not to declare it for other compilers than MSVC that requires it. (If ICL support later requires it, the condition can be extended later to include both of them.) This also implies that code that is built to link to a certain library as a DLL can't link to the same library as a static library. Therefore, we only allow building either static or shared but not both at the same time. (That is, static libraries as such can be, and actually are, built - this is used for linking the test tools to internal symbols in the libraries - but e.g. libavformat built to link to libavcodec as a DLL cannot link statically to libavcodec.) Also, linking to DLLs is slightly different from linking to shared libraries on other platforms. DLLs use a thing called import libraries, which is basically a stub library allowing the linker to know which symbols exist in the DLL and what name the DLL will have at runtime. In mingw/gcc, the import library is usually named libfoo.dll.a, which goes next to a static library named libfoo.a. This allows gcc to pick the dynamic one, if available, from the normal -lfoo switches, just as it does for libfoo.a vs libfoo.so on Unix. On MSVC however, you need to literally specify the name of the import library instead of the static library. Signed-off-by: Martin Storsjö <martin@martin.st>
156 lines
4.7 KiB
C
156 lines
4.7 KiB
C
/*
|
|
* MJPEG encoder and decoder
|
|
* Copyright (c) 2000, 2001 Fabrice Bellard
|
|
* Copyright (c) 2003 Alex Beregszaszi
|
|
* Copyright (c) 2003-2004 Michael Niedermayer
|
|
*
|
|
* Support for external huffman table, various fixes (AVID workaround),
|
|
* aspecting, new decode_frame mechanism and apple mjpeg-b support
|
|
* by Alex Beregszaszi
|
|
*
|
|
* This file is part of Libav.
|
|
*
|
|
* Libav is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
*
|
|
* Libav is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with Libav; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
/**
|
|
* @file
|
|
* MJPEG encoder and decoder.
|
|
*/
|
|
|
|
#ifndef AVCODEC_MJPEG_H
|
|
#define AVCODEC_MJPEG_H
|
|
|
|
#include "avcodec.h"
|
|
#include "put_bits.h"
|
|
|
|
|
|
/* JPEG marker codes */
|
|
typedef enum {
|
|
/* start of frame */
|
|
SOF0 = 0xc0, /* baseline */
|
|
SOF1 = 0xc1, /* extended sequential, huffman */
|
|
SOF2 = 0xc2, /* progressive, huffman */
|
|
SOF3 = 0xc3, /* lossless, huffman */
|
|
|
|
SOF5 = 0xc5, /* differential sequential, huffman */
|
|
SOF6 = 0xc6, /* differential progressive, huffman */
|
|
SOF7 = 0xc7, /* differential lossless, huffman */
|
|
JPG = 0xc8, /* reserved for JPEG extension */
|
|
SOF9 = 0xc9, /* extended sequential, arithmetic */
|
|
SOF10 = 0xca, /* progressive, arithmetic */
|
|
SOF11 = 0xcb, /* lossless, arithmetic */
|
|
|
|
SOF13 = 0xcd, /* differential sequential, arithmetic */
|
|
SOF14 = 0xce, /* differential progressive, arithmetic */
|
|
SOF15 = 0xcf, /* differential lossless, arithmetic */
|
|
|
|
DHT = 0xc4, /* define huffman tables */
|
|
|
|
DAC = 0xcc, /* define arithmetic-coding conditioning */
|
|
|
|
/* restart with modulo 8 count "m" */
|
|
RST0 = 0xd0,
|
|
RST1 = 0xd1,
|
|
RST2 = 0xd2,
|
|
RST3 = 0xd3,
|
|
RST4 = 0xd4,
|
|
RST5 = 0xd5,
|
|
RST6 = 0xd6,
|
|
RST7 = 0xd7,
|
|
|
|
SOI = 0xd8, /* start of image */
|
|
EOI = 0xd9, /* end of image */
|
|
SOS = 0xda, /* start of scan */
|
|
DQT = 0xdb, /* define quantization tables */
|
|
DNL = 0xdc, /* define number of lines */
|
|
DRI = 0xdd, /* define restart interval */
|
|
DHP = 0xde, /* define hierarchical progression */
|
|
EXP = 0xdf, /* expand reference components */
|
|
|
|
APP0 = 0xe0,
|
|
APP1 = 0xe1,
|
|
APP2 = 0xe2,
|
|
APP3 = 0xe3,
|
|
APP4 = 0xe4,
|
|
APP5 = 0xe5,
|
|
APP6 = 0xe6,
|
|
APP7 = 0xe7,
|
|
APP8 = 0xe8,
|
|
APP9 = 0xe9,
|
|
APP10 = 0xea,
|
|
APP11 = 0xeb,
|
|
APP12 = 0xec,
|
|
APP13 = 0xed,
|
|
APP14 = 0xee,
|
|
APP15 = 0xef,
|
|
|
|
JPG0 = 0xf0,
|
|
JPG1 = 0xf1,
|
|
JPG2 = 0xf2,
|
|
JPG3 = 0xf3,
|
|
JPG4 = 0xf4,
|
|
JPG5 = 0xf5,
|
|
JPG6 = 0xf6,
|
|
SOF48 = 0xf7, ///< JPEG-LS
|
|
LSE = 0xf8, ///< JPEG-LS extension parameters
|
|
JPG9 = 0xf9,
|
|
JPG10 = 0xfa,
|
|
JPG11 = 0xfb,
|
|
JPG12 = 0xfc,
|
|
JPG13 = 0xfd,
|
|
|
|
COM = 0xfe, /* comment */
|
|
|
|
TEM = 0x01, /* temporary private use for arithmetic coding */
|
|
|
|
/* 0x02 -> 0xbf reserved */
|
|
} JPEG_MARKER;
|
|
|
|
static inline void put_marker(PutBitContext *p, int code)
|
|
{
|
|
put_bits(p, 8, 0xff);
|
|
put_bits(p, 8, code);
|
|
}
|
|
|
|
#define PREDICT(ret, topleft, top, left, predictor)\
|
|
switch(predictor){\
|
|
case 1: ret= left; break;\
|
|
case 2: ret= top; break;\
|
|
case 3: ret= topleft; break;\
|
|
case 4: ret= left + top - topleft; break;\
|
|
case 5: ret= left + ((top - topleft)>>1); break;\
|
|
case 6: ret= top + ((left - topleft)>>1); break;\
|
|
default:\
|
|
case 7: ret= (left + top)>>1; break;\
|
|
}
|
|
|
|
extern av_export const uint8_t avpriv_mjpeg_bits_dc_luminance[];
|
|
extern av_export const uint8_t avpriv_mjpeg_val_dc[];
|
|
|
|
extern av_export const uint8_t avpriv_mjpeg_bits_dc_chrominance[];
|
|
|
|
extern av_export const uint8_t avpriv_mjpeg_bits_ac_luminance[];
|
|
extern av_export const uint8_t avpriv_mjpeg_val_ac_luminance[];
|
|
|
|
extern av_export const uint8_t avpriv_mjpeg_bits_ac_chrominance[];
|
|
extern av_export const uint8_t avpriv_mjpeg_val_ac_chrominance[];
|
|
|
|
void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code,
|
|
const uint8_t *bits_table,
|
|
const uint8_t *val_table);
|
|
|
|
#endif /* AVCODEC_MJPEG_H */
|