Compare commits
65 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
b38b6b2798 | ||
![]() |
7fc85451fd | ||
![]() |
42c8fdb943 | ||
![]() |
1450d6e637 | ||
![]() |
a99a35c8ea | ||
![]() |
a582b028a4 | ||
![]() |
5d833dd299 | ||
![]() |
01f1201267 | ||
![]() |
f4e34d1614 | ||
![]() |
61f55565fb | ||
![]() |
b6b46db9e4 | ||
![]() |
21d99be9dc | ||
![]() |
7b6b9be861 | ||
![]() |
374409eb1a | ||
![]() |
a352fedb24 | ||
![]() |
c92068430d | ||
![]() |
274a5b7cdb | ||
![]() |
95345e942c | ||
![]() |
87757508ab | ||
![]() |
f66418afba | ||
![]() |
7371b0ca6f | ||
![]() |
c5cbda5079 | ||
![]() |
8893f7d815 | ||
![]() |
7c772ccd27 | ||
![]() |
cf82c5cd5b | ||
![]() |
cb8577a4da | ||
![]() |
b55b34f862 | ||
![]() |
609d299ed0 | ||
![]() |
01a0612c70 | ||
![]() |
dcf1830a15 | ||
![]() |
0a48a67e57 | ||
![]() |
72ac64544f | ||
![]() |
b62c0c0bce | ||
![]() |
00498a7e59 | ||
![]() |
06107e9605 | ||
![]() |
ce993ce791 | ||
![]() |
c0b90d4088 | ||
![]() |
b7b61ff6a3 | ||
![]() |
7a6e47b99d | ||
![]() |
f84c349b3b | ||
![]() |
26f732e21d | ||
![]() |
82b2dd5ee4 | ||
![]() |
e82ddde05a | ||
![]() |
07f5da6128 | ||
![]() |
e845455225 | ||
![]() |
3fedb3e65c | ||
![]() |
1986380df2 | ||
![]() |
df3850db49 | ||
![]() |
082b4f8348 | ||
![]() |
788c313b50 | ||
![]() |
779d7610c7 | ||
![]() |
56629aa012 | ||
![]() |
33651e3edf | ||
![]() |
d46aada5c2 | ||
![]() |
66b1f210c0 | ||
![]() |
d4b98d475f | ||
![]() |
8d8962ca3e | ||
![]() |
329559ae50 | ||
![]() |
0b3a88fe15 | ||
![]() |
563fe360c3 | ||
![]() |
73a502dd43 | ||
![]() |
ea189b77eb | ||
![]() |
2ebd47841f | ||
![]() |
9d7244c4c6 | ||
![]() |
7aee089978 |
2
Doxyfile
2
Doxyfile
@@ -31,7 +31,7 @@ PROJECT_NAME = FFmpeg
|
||||
# This could be handy for archiving the generated documentation or
|
||||
# if some version control system is used.
|
||||
|
||||
PROJECT_NUMBER = 0.8.12
|
||||
PROJECT_NUMBER = 0.7.6
|
||||
|
||||
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
|
||||
# base path where the generated documentation will be put.
|
||||
|
@@ -19,7 +19,7 @@ ffmpeg:
|
||||
ffmpeg.c Michael Niedermayer
|
||||
|
||||
ffplay:
|
||||
ffplay.c Marton Balint
|
||||
ffplay.c Michael Niedermayer
|
||||
|
||||
ffprobe:
|
||||
ffprobe.c Stefano Sabatini
|
||||
|
4
configure
vendored
4
configure
vendored
@@ -2203,7 +2203,7 @@ case "$arch" in
|
||||
arch="sparc"
|
||||
subarch="sparc64"
|
||||
;;
|
||||
i[3-6]86|i86pc|BePC|x86pc|x86_64|x86_32|amd64)
|
||||
i[3-6]86|i86pc|BePC|x86pc|x86_64|amd64)
|
||||
arch="x86"
|
||||
;;
|
||||
esac
|
||||
@@ -3164,7 +3164,7 @@ check_deps $CONFIG_LIST \
|
||||
|
||||
enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; }
|
||||
|
||||
if test $target_os = "haiku"; then
|
||||
if test $target_os == "haiku"; then
|
||||
disable memalign
|
||||
disable posix_memalign
|
||||
fi
|
||||
|
@@ -13,7 +13,6 @@ libavutil: 2011-04-18
|
||||
|
||||
API changes, most recent first:
|
||||
|
||||
|
||||
2011-06-19 - xxxxxxx - lavfi 2.23.0 - avfilter.h
|
||||
Add layout negotiation fields and helper functions.
|
||||
|
||||
@@ -44,12 +43,6 @@ API changes, most recent first:
|
||||
2011-06-12 - xxxxxxx - lavfi 2.16.0 - avfilter_graph_parse()
|
||||
Change avfilter_graph_parse() signature.
|
||||
|
||||
2011-07-10 - xxxxxxx - lavf 53.3.0
|
||||
Add avformat_find_stream_info(), deprecate av_find_stream_info().
|
||||
|
||||
2011-07-10 - xxxxxxx - lavc 53.6.0
|
||||
Add avcodec_open2(), deprecate avcodec_open().
|
||||
|
||||
2011-06-xx - xxxxxxx - lavf 53.2.0 - avformat.h
|
||||
Add avformat_open_input and avformat_write_header().
|
||||
Deprecate av_open_input_stream, av_open_input_file,
|
||||
|
@@ -2,7 +2,7 @@ Release Notes
|
||||
=============
|
||||
|
||||
* 0.8 "Love" June, 2011
|
||||
* 0.7 "Peace" June, 2011 (identical to 0.8 but using 0.6 ABI/API)
|
||||
* 0.7.1 "Peace" June, 2011 (identical to 0.8 but using 0.6 ABI/API)
|
||||
|
||||
|
||||
General notes
|
||||
|
@@ -479,7 +479,7 @@ int main(int argc, char **argv)
|
||||
|
||||
/* open the output file, if needed */
|
||||
if (!(fmt->flags & AVFMT_NOFILE)) {
|
||||
if (avio_open(&oc->pb, filename, AVIO_FLAG_WRITE) < 0) {
|
||||
if (avio_open(&oc->pb, filename, AVIO_WRONLY) < 0) {
|
||||
fprintf(stderr, "Could not open '%s'\n", filename);
|
||||
exit(1);
|
||||
}
|
||||
|
@@ -1760,9 +1760,9 @@ interlaced video, accepts one of the following values:
|
||||
|
||||
@table @option
|
||||
@item 0
|
||||
assume top field first
|
||||
@item 1
|
||||
assume bottom field first
|
||||
@item 1
|
||||
assume top field first
|
||||
@item -1
|
||||
enable automatic detection
|
||||
@end table
|
||||
|
11
ffmpeg.c
11
ffmpeg.c
@@ -31,7 +31,7 @@
|
||||
#include "libavformat/avformat.h"
|
||||
#include "libavdevice/avdevice.h"
|
||||
#include "libswscale/swscale.h"
|
||||
#include "libavutil/opt.h"
|
||||
#include "libavcodec/opt.h"
|
||||
#include "libavcodec/audioconvert.h"
|
||||
#include "libavutil/audioconvert.h"
|
||||
#include "libavutil/parseutils.h"
|
||||
@@ -113,7 +113,9 @@ typedef struct AVChapterMap {
|
||||
static const OptionDef options[];
|
||||
|
||||
#define MAX_FILES 100
|
||||
#if !FF_API_MAX_STREAMS
|
||||
#define MAX_STREAMS 1024 /* arbitrary sanity check value */
|
||||
#endif
|
||||
|
||||
static const char *last_asked_format = NULL;
|
||||
static int64_t input_files_ts_offset[MAX_FILES];
|
||||
@@ -712,7 +714,6 @@ static int read_ffserver_streams(AVFormatContext *s, const char *filename)
|
||||
return err;
|
||||
/* copy stream format */
|
||||
s->nb_streams = 0;
|
||||
s->streams = av_mallocz(sizeof(AVStream *) * ic->nb_streams);
|
||||
for(i=0;i<ic->nb_streams;i++) {
|
||||
AVStream *st;
|
||||
AVCodec *codec;
|
||||
@@ -3957,7 +3958,7 @@ static int opt_output_file(const char *opt, const char *filename)
|
||||
/* check filename in case of an image number is expected */
|
||||
if (oc->oformat->flags & AVFMT_NEEDNUMBER) {
|
||||
if (!av_filename_number_test(oc->filename)) {
|
||||
print_error(oc->filename, AVERROR(EINVAL));
|
||||
print_error(oc->filename, AVERROR_NUMEXPECTED);
|
||||
ffmpeg_exit(1);
|
||||
}
|
||||
}
|
||||
@@ -3968,7 +3969,7 @@ static int opt_output_file(const char *opt, const char *filename)
|
||||
(strchr(filename, ':') == NULL ||
|
||||
filename[1] == ':' ||
|
||||
av_strstart(filename, "file:", NULL))) {
|
||||
if (avio_check(filename, 0) == 0) {
|
||||
if (url_exist(filename)) {
|
||||
if (!using_stdin) {
|
||||
fprintf(stderr,"File '%s' already exists. Overwrite ? [y/N] ", filename);
|
||||
fflush(stderr);
|
||||
@@ -3985,7 +3986,7 @@ static int opt_output_file(const char *opt, const char *filename)
|
||||
}
|
||||
|
||||
/* open the file */
|
||||
if ((err = avio_open(&oc->pb, filename, AVIO_FLAG_WRITE)) < 0) {
|
||||
if ((err = avio_open(&oc->pb, filename, AVIO_WRONLY)) < 0) {
|
||||
print_error(filename, err);
|
||||
ffmpeg_exit(1);
|
||||
}
|
||||
|
9
ffplay.c
9
ffplay.c
@@ -35,7 +35,7 @@
|
||||
#include "libavdevice/avdevice.h"
|
||||
#include "libswscale/swscale.h"
|
||||
#include "libavcodec/audioconvert.h"
|
||||
#include "libavutil/opt.h"
|
||||
#include "libavcodec/opt.h"
|
||||
#include "libavcodec/avfft.h"
|
||||
|
||||
#if CONFIG_AVFILTER
|
||||
@@ -2135,12 +2135,7 @@ static int stream_component_open(VideoState *is, int stream_index)
|
||||
|
||||
avctx->workaround_bugs = workaround_bugs;
|
||||
avctx->lowres = lowres;
|
||||
if(avctx->lowres > codec->max_lowres){
|
||||
av_log(avctx, AV_LOG_WARNING, "The maximum value for lowres supported by the decoder is %d\n",
|
||||
codec->max_lowres);
|
||||
avctx->lowres= codec->max_lowres;
|
||||
}
|
||||
if(avctx->lowres) avctx->flags |= CODEC_FLAG_EMU_EDGE;
|
||||
if(lowres) avctx->flags |= CODEC_FLAG_EMU_EDGE;
|
||||
avctx->idct_algo= idct;
|
||||
if(fast) avctx->flags2 |= CODEC_FLAG2_FAST;
|
||||
avctx->skip_frame= skip_frame;
|
||||
|
@@ -23,7 +23,7 @@
|
||||
|
||||
#include "libavformat/avformat.h"
|
||||
#include "libavcodec/avcodec.h"
|
||||
#include "libavutil/opt.h"
|
||||
#include "libavcodec/opt.h"
|
||||
#include "libavutil/pixdesc.h"
|
||||
#include "libavutil/dict.h"
|
||||
#include "libavdevice/avdevice.h"
|
||||
|
43
ffserver.c
43
ffserver.c
@@ -39,7 +39,7 @@
|
||||
#include "libavutil/dict.h"
|
||||
#include "libavutil/random_seed.h"
|
||||
#include "libavutil/parseutils.h"
|
||||
#include "libavutil/opt.h"
|
||||
#include "libavcodec/opt.h"
|
||||
#include <stdarg.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
@@ -94,7 +94,9 @@ static const char *http_state[] = {
|
||||
"RTSP_SEND_PACKET",
|
||||
};
|
||||
|
||||
#if !FF_API_MAX_STREAMS
|
||||
#define MAX_STREAMS 20
|
||||
#endif
|
||||
|
||||
#define IOBUFFER_INIT_SIZE 8192
|
||||
|
||||
@@ -516,7 +518,6 @@ static int socket_open_listen(struct sockaddr_in *my_addr)
|
||||
tmp = 1;
|
||||
setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &tmp, sizeof(tmp));
|
||||
|
||||
my_addr->sin_family = AF_INET;
|
||||
if (bind (server_fd, (struct sockaddr *) my_addr, sizeof (*my_addr)) < 0) {
|
||||
char bindmsg[32];
|
||||
snprintf(bindmsg, sizeof(bindmsg), "bind(port %d)", ntohs(my_addr->sin_port));
|
||||
@@ -2230,11 +2231,11 @@ static int http_prepare_data(HTTPContext *c)
|
||||
av_dict_set(&c->fmt_ctx.metadata, "copyright", c->stream->copyright, 0);
|
||||
av_dict_set(&c->fmt_ctx.metadata, "title" , c->stream->title , 0);
|
||||
|
||||
c->fmt_ctx.streams = av_mallocz(sizeof(AVStream *) * c->stream->nb_streams);
|
||||
|
||||
for(i=0;i<c->stream->nb_streams;i++) {
|
||||
AVStream *st;
|
||||
AVStream *src;
|
||||
c->fmt_ctx.streams[i] = av_mallocz(sizeof(AVStream));
|
||||
st = av_mallocz(sizeof(AVStream));
|
||||
c->fmt_ctx.streams[i] = st;
|
||||
/* if file or feed, then just take streams from FFStream struct */
|
||||
if (!c->stream->feed ||
|
||||
c->stream->feed == c->stream)
|
||||
@@ -2242,9 +2243,9 @@ static int http_prepare_data(HTTPContext *c)
|
||||
else
|
||||
src = c->stream->feed->streams[c->stream->feed_streams[i]];
|
||||
|
||||
*(c->fmt_ctx.streams[i]) = *src;
|
||||
c->fmt_ctx.streams[i]->priv_data = 0;
|
||||
c->fmt_ctx.streams[i]->codec->frame_number = 0; /* XXX: should be done in
|
||||
*st = *src;
|
||||
st->priv_data = 0;
|
||||
st->codec->frame_number = 0; /* XXX: should be done in
|
||||
AVStream, not in codec */
|
||||
}
|
||||
/* set output format parameters */
|
||||
@@ -2942,9 +2943,11 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer,
|
||||
snprintf(avc->filename, 1024, "rtp://0.0.0.0");
|
||||
}
|
||||
|
||||
#if !FF_API_MAX_STREAMS
|
||||
if (avc->nb_streams >= INT_MAX/sizeof(*avc->streams) ||
|
||||
!(avc->streams = av_malloc(avc->nb_streams * sizeof(*avc->streams))))
|
||||
goto sdp_done;
|
||||
#endif
|
||||
if (avc->nb_streams >= INT_MAX/sizeof(*avs) ||
|
||||
!(avs = av_malloc(avc->nb_streams * sizeof(*avs))))
|
||||
goto sdp_done;
|
||||
@@ -2957,8 +2960,10 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer,
|
||||
av_sdp_create(&avc, 1, *pbuffer, 2048);
|
||||
|
||||
sdp_done:
|
||||
#if !FF_API_MAX_STREAMS
|
||||
av_free(avc->streams);
|
||||
av_dict_free(&avc->metadata);
|
||||
#endif
|
||||
av_metadata_free(&avc->metadata);
|
||||
av_free(avc);
|
||||
av_free(avs);
|
||||
|
||||
@@ -3386,9 +3391,6 @@ static int rtp_new_av_stream(HTTPContext *c,
|
||||
if (!st)
|
||||
goto fail;
|
||||
ctx->nb_streams = 1;
|
||||
ctx->streams = av_mallocz(sizeof(AVStream *) * ctx->nb_streams);
|
||||
if (!ctx->streams)
|
||||
goto fail;
|
||||
ctx->streams[0] = st;
|
||||
|
||||
if (!c->stream->feed ||
|
||||
@@ -3422,7 +3424,7 @@ static int rtp_new_av_stream(HTTPContext *c,
|
||||
"rtp://%s:%d", ipaddr, ntohs(dest_addr->sin_port));
|
||||
}
|
||||
|
||||
if (url_open(&h, ctx->filename, AVIO_FLAG_WRITE) < 0)
|
||||
if (url_open(&h, ctx->filename, AVIO_WRONLY) < 0)
|
||||
goto fail;
|
||||
c->rtp_handles[stream_index] = h;
|
||||
max_packet_size = url_get_max_packet_size(h);
|
||||
@@ -3675,7 +3677,7 @@ static void build_feed_streams(void)
|
||||
for(feed = first_feed; feed != NULL; feed = feed->next_feed) {
|
||||
int fd;
|
||||
|
||||
if (avio_check(feed->feed_filename, AVIO_FLAG_READ) > 0) {
|
||||
if (url_exist(feed->feed_filename)) {
|
||||
/* See if it matches */
|
||||
AVFormatContext *s = NULL;
|
||||
int matches = 0;
|
||||
@@ -3748,7 +3750,7 @@ static void build_feed_streams(void)
|
||||
unlink(feed->feed_filename);
|
||||
}
|
||||
}
|
||||
if (avio_check(feed->feed_filename, AVIO_FLAG_WRITE) <= 0) {
|
||||
if (!url_exist(feed->feed_filename)) {
|
||||
AVFormatContext s1 = {0}, *s = &s1;
|
||||
|
||||
if (feed->readonly) {
|
||||
@@ -3758,15 +3760,20 @@ static void build_feed_streams(void)
|
||||
}
|
||||
|
||||
/* only write the header of the ffm file */
|
||||
if (avio_open(&s->pb, feed->feed_filename, AVIO_FLAG_WRITE) < 0) {
|
||||
if (avio_open(&s->pb, feed->feed_filename, AVIO_WRONLY) < 0) {
|
||||
http_log("Could not open output feed file '%s'\n",
|
||||
feed->feed_filename);
|
||||
exit(1);
|
||||
}
|
||||
s->oformat = feed->fmt;
|
||||
s->nb_streams = feed->nb_streams;
|
||||
s->streams = feed->streams;
|
||||
if (avformat_write_header(s, NULL) < 0) {
|
||||
for(i=0;i<s->nb_streams;i++) {
|
||||
AVStream *st;
|
||||
st = feed->streams[i];
|
||||
s->streams[i] = st;
|
||||
}
|
||||
av_set_parameters(s, NULL);
|
||||
if (av_write_header(s) < 0) {
|
||||
http_log("Container doesn't supports the required parameters\n");
|
||||
exit(1);
|
||||
}
|
||||
|
@@ -279,7 +279,7 @@ static void init_mv(FourXContext *f){
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline void mcdc(uint16_t *dst, uint16_t *src, int log2w, int h, int stride, int scale, unsigned dc){
|
||||
static inline void mcdc(uint16_t *dst, uint16_t *src, int log2w, int h, int stride, int scale, int dc){
|
||||
int i;
|
||||
dc*= 0x10001;
|
||||
|
||||
@@ -694,13 +694,10 @@ static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length){
|
||||
unsigned int prestream_size;
|
||||
const uint8_t *prestream;
|
||||
|
||||
if (length < bitstream_size + 12) {
|
||||
av_log(f->avctx, AV_LOG_ERROR, "packet size too small\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
prestream_size = 4 * AV_RL32(buf + bitstream_size + 4);
|
||||
prestream = buf + bitstream_size + 12;
|
||||
if (bitstream_size > (1<<26) || length < bitstream_size + 12)
|
||||
return -1;
|
||||
prestream_size = 4*AV_RL32(buf + bitstream_size + 4);
|
||||
prestream = buf + bitstream_size + 12;
|
||||
|
||||
if (prestream_size > (1<<26) ||
|
||||
prestream_size != length - (bitstream_size + 12)){
|
||||
|
@@ -50,8 +50,6 @@ typedef struct EightBpsContext {
|
||||
|
||||
unsigned char planes;
|
||||
unsigned char planemap[4];
|
||||
|
||||
uint32_t pal[256];
|
||||
} EightBpsContext;
|
||||
|
||||
|
||||
@@ -131,16 +129,13 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
|
||||
}
|
||||
}
|
||||
|
||||
if (avctx->bits_per_coded_sample <= 8) {
|
||||
const uint8_t *pal = av_packet_get_side_data(avpkt,
|
||||
AV_PKT_DATA_PALETTE,
|
||||
NULL);
|
||||
if (pal) {
|
||||
if (avctx->palctrl) {
|
||||
memcpy (c->pic.data[1], avctx->palctrl->palette, AVPALETTE_SIZE);
|
||||
if (avctx->palctrl->palette_changed) {
|
||||
c->pic.palette_has_changed = 1;
|
||||
memcpy(c->pal, pal, AVPALETTE_SIZE);
|
||||
}
|
||||
|
||||
memcpy (c->pic.data[1], c->pal, AVPALETTE_SIZE);
|
||||
avctx->palctrl->palette_changed = 0;
|
||||
} else
|
||||
c->pic.palette_has_changed = 0;
|
||||
}
|
||||
|
||||
*data_size = sizeof(AVFrame);
|
||||
@@ -170,6 +165,10 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
avctx->pix_fmt = PIX_FMT_PAL8;
|
||||
c->planes = 1;
|
||||
c->planemap[0] = 0; // 1st plane is palette indexes
|
||||
if (avctx->palctrl == NULL) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Error: PAL8 format but no palette from demuxer.\n");
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case 24:
|
||||
avctx->pix_fmt = avctx->get_format(avctx, pixfmt_rgb24);
|
||||
|
@@ -44,7 +44,7 @@ typedef struct EightSvxContext {
|
||||
/* buffer used to store the whole audio decoded/interleaved chunk,
|
||||
* which is sent with the first packet */
|
||||
uint8_t *samples;
|
||||
int64_t samples_size;
|
||||
size_t samples_size;
|
||||
int samples_idx;
|
||||
} EightSvxContext;
|
||||
|
||||
|
@@ -15,6 +15,7 @@ OBJS = allcodecs.o \
|
||||
fmtconvert.o \
|
||||
imgconvert.o \
|
||||
jrevdct.o \
|
||||
opt.o \
|
||||
options.o \
|
||||
parser.o \
|
||||
raw.o \
|
||||
|
@@ -754,20 +754,19 @@ static int decode_band_types(AACContext *ac, enum BandType band_type[120],
|
||||
av_log(ac->avctx, AV_LOG_ERROR, "invalid band type\n");
|
||||
return -1;
|
||||
}
|
||||
do {
|
||||
sect_len_incr = get_bits(gb, bits);
|
||||
while ((sect_len_incr = get_bits(gb, bits)) == (1 << bits) - 1)
|
||||
sect_end += sect_len_incr;
|
||||
if (get_bits_left(gb) < 0) {
|
||||
av_log(ac->avctx, AV_LOG_ERROR, overread_err);
|
||||
return -1;
|
||||
}
|
||||
if (sect_end > ics->max_sfb) {
|
||||
av_log(ac->avctx, AV_LOG_ERROR,
|
||||
"Number of bands (%d) exceeds limit (%d).\n",
|
||||
sect_end, ics->max_sfb);
|
||||
return -1;
|
||||
}
|
||||
} while (sect_len_incr == (1 << bits) - 1);
|
||||
sect_end += sect_len_incr;
|
||||
if (get_bits_left(gb) < 0) {
|
||||
av_log(ac->avctx, AV_LOG_ERROR, overread_err);
|
||||
return -1;
|
||||
}
|
||||
if (sect_end > ics->max_sfb) {
|
||||
av_log(ac->avctx, AV_LOG_ERROR,
|
||||
"Number of bands (%d) exceeds limit (%d).\n",
|
||||
sect_end, ics->max_sfb);
|
||||
return -1;
|
||||
}
|
||||
for (; k < sect_end; k++) {
|
||||
band_type [idx] = sect_band_type;
|
||||
band_type_run_end[idx++] = sect_end;
|
||||
@@ -1091,7 +1090,7 @@ static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024],
|
||||
GET_VLC(code, re, gb, vlc_tab, 8, 2);
|
||||
cb_idx = cb_vector_idx[code];
|
||||
nnz = cb_idx >> 8 & 15;
|
||||
bits = nnz ? GET_CACHE(re, gb) : 0;
|
||||
bits = SHOW_UBITS(re, gb, nnz) << (32-nnz);
|
||||
LAST_SKIP_BITS(re, gb, nnz);
|
||||
cf = VMUL4S(cf, vq, cb_idx, bits, sf + idx);
|
||||
} while (len -= 4);
|
||||
@@ -1131,7 +1130,7 @@ static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024],
|
||||
GET_VLC(code, re, gb, vlc_tab, 8, 2);
|
||||
cb_idx = cb_vector_idx[code];
|
||||
nnz = cb_idx >> 8 & 15;
|
||||
sign = nnz ? SHOW_UBITS(re, gb, nnz) << (cb_idx >> 12) : 0;
|
||||
sign = SHOW_UBITS(re, gb, nnz) << (cb_idx >> 12);
|
||||
LAST_SKIP_BITS(re, gb, nnz);
|
||||
cf = VMUL2S(cf, vq, cb_idx, sign, sf + idx);
|
||||
} while (len -= 2);
|
||||
|
@@ -1183,15 +1183,14 @@ static void sbr_qmf_synthesis(DSPContext *dsp, FFTContext *mdct,
|
||||
{
|
||||
int i, n;
|
||||
const float *sbr_qmf_window = div ? sbr_qmf_window_ds : sbr_qmf_window_us;
|
||||
const int step = 128 >> div;
|
||||
float *v;
|
||||
for (i = 0; i < 32; i++) {
|
||||
if (*v_off < step) {
|
||||
if (*v_off == 0) {
|
||||
int saved_samples = (1280 - 128) >> div;
|
||||
memcpy(&v0[SBR_SYNTHESIS_BUF_SIZE - saved_samples], v0, saved_samples * sizeof(float));
|
||||
*v_off = SBR_SYNTHESIS_BUF_SIZE - saved_samples - step;
|
||||
*v_off = SBR_SYNTHESIS_BUF_SIZE - saved_samples - (128 >> div);
|
||||
} else {
|
||||
*v_off -= step;
|
||||
*v_off -= 128 >> div;
|
||||
}
|
||||
v = v0 + *v_off;
|
||||
if (div) {
|
||||
|
@@ -108,7 +108,7 @@ static void ac3_bit_alloc_calc_bap_c(int16_t *mask, int16_t *psd,
|
||||
int snr_offset, int floor,
|
||||
const uint8_t *bap_tab, uint8_t *bap)
|
||||
{
|
||||
int bin, band, band_end;
|
||||
int bin, band;
|
||||
|
||||
/* special case, if snr offset is -960, set all bap's to zero */
|
||||
if (snr_offset == -960) {
|
||||
@@ -120,14 +120,12 @@ static void ac3_bit_alloc_calc_bap_c(int16_t *mask, int16_t *psd,
|
||||
band = ff_ac3_bin_to_band_tab[start];
|
||||
do {
|
||||
int m = (FFMAX(mask[band] - snr_offset - floor, 0) & 0x1FE0) + floor;
|
||||
band_end = ff_ac3_band_start_tab[++band];
|
||||
band_end = FFMIN(band_end, end);
|
||||
|
||||
int band_end = FFMIN(ff_ac3_band_start_tab[band+1], end);
|
||||
for (; bin < band_end; bin++) {
|
||||
int address = av_clip((psd[bin] - m) >> 5, 0, 63);
|
||||
bap[bin] = bap_tab[address];
|
||||
}
|
||||
} while (end > band_end);
|
||||
} while (end > ff_ac3_band_start_tab[band++]);
|
||||
}
|
||||
|
||||
static void ac3_update_bap_counts_c(uint16_t mant_cnt[16], uint8_t *bap,
|
||||
|
@@ -778,13 +778,9 @@ static int adpcm_encode_frame(AVCodecContext *avctx,
|
||||
static av_cold int adpcm_decode_init(AVCodecContext * avctx)
|
||||
{
|
||||
ADPCMContext *c = avctx->priv_data;
|
||||
unsigned int min_channels = 1;
|
||||
unsigned int max_channels = 2;
|
||||
|
||||
switch(avctx->codec->id) {
|
||||
case CODEC_ID_ADPCM_EA:
|
||||
min_channels = 2;
|
||||
break;
|
||||
case CODEC_ID_ADPCM_EA_R1:
|
||||
case CODEC_ID_ADPCM_EA_R2:
|
||||
case CODEC_ID_ADPCM_EA_R3:
|
||||
@@ -792,10 +788,8 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx)
|
||||
max_channels = 6;
|
||||
break;
|
||||
}
|
||||
|
||||
if (avctx->channels < min_channels || avctx->channels > max_channels) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid number of channels\n");
|
||||
return AVERROR(EINVAL);
|
||||
if(avctx->channels > max_channels){
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch(avctx->codec->id) {
|
||||
@@ -1366,17 +1360,11 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
|
||||
}
|
||||
break;
|
||||
case CODEC_ID_ADPCM_EA:
|
||||
/* Each EA ADPCM frame has a 12-byte header followed by 30-byte pieces,
|
||||
each coding 28 stereo samples. */
|
||||
if (buf_size < 12) {
|
||||
av_log(avctx, AV_LOG_ERROR, "frame too small\n");
|
||||
return AVERROR(EINVAL);
|
||||
if (buf_size < 12 || AV_RL32(src) > (buf_size - 12)/30*28) {
|
||||
src += buf_size;
|
||||
break;
|
||||
}
|
||||
samples_in_chunk = AV_RL32(src);
|
||||
if (samples_in_chunk / 28 > (buf_size - 12) / 30) {
|
||||
av_log(avctx, AV_LOG_ERROR, "invalid frame\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
src += 4;
|
||||
current_left_sample = (int16_t)bytestream_get_le16(&src);
|
||||
previous_left_sample = (int16_t)bytestream_get_le16(&src);
|
||||
|
@@ -1010,7 +1010,7 @@ static void zero_remaining(unsigned int b, unsigned int b_max,
|
||||
{
|
||||
unsigned int count = 0;
|
||||
|
||||
for (; b < b_max; b++)
|
||||
while (b < b_max)
|
||||
count += div_blocks[b];
|
||||
|
||||
if (count)
|
||||
|
@@ -163,18 +163,6 @@ typedef struct APEContext {
|
||||
|
||||
// TODO: dsputilize
|
||||
|
||||
static av_cold int ape_decode_close(AVCodecContext * avctx)
|
||||
{
|
||||
APEContext *s = avctx->priv_data;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < APE_FILTER_LEVELS; i++)
|
||||
av_freep(&s->filterbuf[i]);
|
||||
|
||||
av_freep(&s->data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static av_cold int ape_decode_init(AVCodecContext * avctx)
|
||||
{
|
||||
APEContext *s = avctx->priv_data;
|
||||
@@ -207,18 +195,25 @@ static av_cold int ape_decode_init(AVCodecContext * avctx)
|
||||
for (i = 0; i < APE_FILTER_LEVELS; i++) {
|
||||
if (!ape_filter_orders[s->fset][i])
|
||||
break;
|
||||
FF_ALLOC_OR_GOTO(avctx, s->filterbuf[i],
|
||||
(ape_filter_orders[s->fset][i] * 3 + HISTORY_SIZE) * 4,
|
||||
filter_alloc_fail);
|
||||
s->filterbuf[i] = av_malloc((ape_filter_orders[s->fset][i] * 3 + HISTORY_SIZE) * 4);
|
||||
}
|
||||
|
||||
dsputil_init(&s->dsp, avctx);
|
||||
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
|
||||
avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
|
||||
return 0;
|
||||
filter_alloc_fail:
|
||||
ape_decode_close(avctx);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
static av_cold int ape_decode_close(AVCodecContext * avctx)
|
||||
{
|
||||
APEContext *s = avctx->priv_data;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < APE_FILTER_LEVELS; i++)
|
||||
av_freep(&s->filterbuf[i]);
|
||||
|
||||
av_freep(&s->data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -802,7 +797,7 @@ static int ape_decode_frame(AVCodecContext * avctx,
|
||||
int buf_size = avpkt->size;
|
||||
APEContext *s = avctx->priv_data;
|
||||
int16_t *samples = data;
|
||||
uint32_t nblocks;
|
||||
int nblocks;
|
||||
int i, n;
|
||||
int blockstodecode;
|
||||
int bytes_used;
|
||||
@@ -819,15 +814,12 @@ static int ape_decode_frame(AVCodecContext * avctx,
|
||||
}
|
||||
|
||||
if(!s->samples){
|
||||
void *tmp_data = av_realloc(s->data, (buf_size + 3) & ~3);
|
||||
if (!tmp_data)
|
||||
return AVERROR(ENOMEM);
|
||||
s->data = tmp_data;
|
||||
s->data = av_realloc(s->data, (buf_size + 3) & ~3);
|
||||
s->dsp.bswap_buf((uint32_t*)s->data, (const uint32_t*)buf, buf_size >> 2);
|
||||
s->ptr = s->last_ptr = s->data;
|
||||
s->data_end = s->data + buf_size;
|
||||
|
||||
nblocks = bytestream_get_be32(&s->ptr);
|
||||
nblocks = s->samples = bytestream_get_be32(&s->ptr);
|
||||
n = bytestream_get_be32(&s->ptr);
|
||||
if(n < 0 || n > 3){
|
||||
av_log(avctx, AV_LOG_ERROR, "Incorrect offset passed\n");
|
||||
@@ -836,13 +828,12 @@ static int ape_decode_frame(AVCodecContext * avctx,
|
||||
}
|
||||
s->ptr += n;
|
||||
|
||||
s->currentframeblocks = nblocks;
|
||||
buf += 4;
|
||||
if (!nblocks || nblocks > INT_MAX) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid sample count: %u.\n", nblocks);
|
||||
if (s->samples <= 0) {
|
||||
*data_size = 0;
|
||||
return AVERROR_INVALIDDATA;
|
||||
return buf_size;
|
||||
}
|
||||
s->currentframeblocks = s->samples = nblocks;
|
||||
|
||||
memset(s->decoded0, 0, sizeof(s->decoded0));
|
||||
memset(s->decoded1, 0, sizeof(s->decoded1));
|
||||
|
@@ -276,7 +276,7 @@ static int atrac1_decode_frame(AVCodecContext *avctx, void *data,
|
||||
const uint8_t *buf = avpkt->data;
|
||||
int buf_size = avpkt->size;
|
||||
AT1Ctx *q = avctx->priv_data;
|
||||
int ch, ret, i, out_size;
|
||||
int ch, ret, i;
|
||||
GetBitContext gb;
|
||||
float* samples = data;
|
||||
|
||||
@@ -286,13 +286,6 @@ static int atrac1_decode_frame(AVCodecContext *avctx, void *data,
|
||||
return -1;
|
||||
}
|
||||
|
||||
out_size = q->channels * AT1_SU_SAMPLES *
|
||||
av_get_bytes_per_sample(avctx->sample_fmt);
|
||||
if (*data_size < out_size) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
for (ch = 0; ch < q->channels; ch++) {
|
||||
AT1SUCtx* su = &q->SUs[ch];
|
||||
|
||||
@@ -325,7 +318,7 @@ static int atrac1_decode_frame(AVCodecContext *avctx, void *data,
|
||||
}
|
||||
}
|
||||
|
||||
*data_size = out_size;
|
||||
*data_size = q->channels * AT1_SU_SAMPLES * sizeof(*samples);
|
||||
return avctx->block_align;
|
||||
}
|
||||
|
||||
@@ -336,11 +329,6 @@ static av_cold int atrac1_decode_init(AVCodecContext *avctx)
|
||||
|
||||
avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
|
||||
|
||||
if (avctx->channels < 1 || avctx->channels > AT1_MAX_CHANNELS) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Unsupported number of channels: %d\n",
|
||||
avctx->channels);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
q->channels = avctx->channels;
|
||||
|
||||
/* Init the mdct transforms */
|
||||
|
@@ -395,8 +395,6 @@ static int decodeTonalComponents (GetBitContext *gb, tonal_component *pComponent
|
||||
|
||||
for (k=0; k<coded_components; k++) {
|
||||
sfIndx = get_bits(gb,6);
|
||||
if (component_count >= 64)
|
||||
return AVERROR_INVALIDDATA;
|
||||
pComponent[component_count].pos = j * 64 + (get_bits(gb,6));
|
||||
max_coded_values = 1024 - pComponent[component_count].pos;
|
||||
coded_values = coded_values_per_component + 1;
|
||||
|
@@ -30,10 +30,15 @@
|
||||
#include "libavutil/samplefmt.h"
|
||||
#include "libavutil/avutil.h"
|
||||
#include "libavutil/cpu.h"
|
||||
#include "libavutil/dict.h"
|
||||
|
||||
#include "libavcodec/version.h"
|
||||
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 53
|
||||
# define FF_INTERNALC_MEM_TYPE unsigned int
|
||||
#else
|
||||
# define FF_INTERNALC_MEM_TYPE size_t
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Identify the syntax and semantics of the bitstream.
|
||||
* The principle is roughly:
|
||||
@@ -112,6 +117,9 @@ enum CodecID {
|
||||
CODEC_ID_QDRAW,
|
||||
CODEC_ID_VIXL,
|
||||
CODEC_ID_QPEG,
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 53
|
||||
CODEC_ID_XVID,
|
||||
#endif
|
||||
CODEC_ID_PNG,
|
||||
CODEC_ID_PPM,
|
||||
CODEC_ID_PBM,
|
||||
@@ -360,6 +368,18 @@ enum CodecID {
|
||||
CODEC_ID_FFMETADATA=0x21000, ///< Dummy codec for streams containing only metadata information.
|
||||
};
|
||||
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 53
|
||||
#define CodecType AVMediaType
|
||||
|
||||
#define CODEC_TYPE_UNKNOWN AVMEDIA_TYPE_UNKNOWN
|
||||
#define CODEC_TYPE_VIDEO AVMEDIA_TYPE_VIDEO
|
||||
#define CODEC_TYPE_AUDIO AVMEDIA_TYPE_AUDIO
|
||||
#define CODEC_TYPE_DATA AVMEDIA_TYPE_DATA
|
||||
#define CODEC_TYPE_SUBTITLE AVMEDIA_TYPE_SUBTITLE
|
||||
#define CODEC_TYPE_ATTACHMENT AVMEDIA_TYPE_ATTACHMENT
|
||||
#define CODEC_TYPE_NB AVMEDIA_TYPE_NB
|
||||
#endif
|
||||
|
||||
#if FF_API_OLD_SAMPLE_FMT
|
||||
#define SampleFormat AVSampleFormat
|
||||
|
||||
@@ -523,7 +543,7 @@ enum AVChromaLocation{
|
||||
/**
|
||||
* LPC analysis type
|
||||
*/
|
||||
enum AVLPCType {
|
||||
attribute_deprecated enum AVLPCType {
|
||||
AV_LPC_TYPE_DEFAULT = -1, ///< use the codec default LPC type
|
||||
AV_LPC_TYPE_NONE = 0, ///< do not use LPC prediction or use all zero coefficients
|
||||
AV_LPC_TYPE_FIXED = 1, ///< fixed LPC coefficients
|
||||
@@ -1071,10 +1091,6 @@ typedef struct AVPanScan{
|
||||
#define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content.
|
||||
#define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update).
|
||||
|
||||
enum AVPacketSideDataType {
|
||||
AV_PKT_DATA_PALETTE,
|
||||
};
|
||||
|
||||
typedef struct AVPacket {
|
||||
/**
|
||||
* Presentation timestamp in AVStream->time_base units; the time at which
|
||||
@@ -1096,17 +1112,6 @@ typedef struct AVPacket {
|
||||
int size;
|
||||
int stream_index;
|
||||
int flags;
|
||||
/**
|
||||
* Additional packet data that can be provided by the container.
|
||||
* Packet can contain several types of side information.
|
||||
*/
|
||||
struct {
|
||||
uint8_t *data;
|
||||
int size;
|
||||
enum AVPacketSideDataType type;
|
||||
} *side_data;
|
||||
int side_data_elems;
|
||||
|
||||
/**
|
||||
* Duration of this packet in AVStream->time_base units, 0 if unknown.
|
||||
* Equals next_pts - this_pts in presentation order.
|
||||
@@ -1136,6 +1141,9 @@ typedef struct AVPacket {
|
||||
int64_t convergence_duration;
|
||||
} AVPacket;
|
||||
#define AV_PKT_FLAG_KEY 0x0001
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 53
|
||||
#define PKT_FLAG_KEY AV_PKT_FLAG_KEY
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Audio Video Frame.
|
||||
@@ -1256,6 +1264,16 @@ typedef struct AVCodecContext {
|
||||
*/
|
||||
enum PixelFormat pix_fmt;
|
||||
|
||||
#if FF_API_RATE_EMU
|
||||
/**
|
||||
* Frame rate emulation. If not zero, the lower layer (i.e. format handler)
|
||||
* has to read frames at native frame rate.
|
||||
* - encoding: Set by user.
|
||||
* - decoding: unused
|
||||
*/
|
||||
attribute_deprecated int rate_emu;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* If non NULL, 'draw_horiz_band' is called by the libavcodec
|
||||
* decoder to draw a horizontal band. It improves cache usage. Not
|
||||
@@ -1300,6 +1318,9 @@ typedef struct AVCodecContext {
|
||||
*/
|
||||
int frame_size;
|
||||
int frame_number; ///< audio or video frame number
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 53
|
||||
int real_pict_num; ///< Returns the real picture number of previous encoded frame.
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Number of frames the decoded output will be delayed relative to
|
||||
@@ -1357,6 +1378,16 @@ typedef struct AVCodecContext {
|
||||
|
||||
int b_frame_strategy;
|
||||
|
||||
#if FF_API_HURRY_UP
|
||||
/**
|
||||
* hurry up amount
|
||||
* - encoding: unused
|
||||
* - decoding: Set by user. 1-> Skip B-frames, 2-> Skip IDCT/dequant too, 5-> Skip everything except header
|
||||
* @deprecated Deprecated in favor of skip_idct and skip_frame.
|
||||
*/
|
||||
attribute_deprecated int hurry_up;
|
||||
#endif
|
||||
|
||||
struct AVCodec *codec;
|
||||
|
||||
void *priv_data;
|
||||
@@ -1474,6 +1505,9 @@ typedef struct AVCodecContext {
|
||||
#define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to an older more strict version of the spec or reference software.
|
||||
#define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences.
|
||||
#define FF_COMPLIANCE_NORMAL 0
|
||||
#if FF_API_INOFFICIAL
|
||||
#define FF_COMPLIANCE_INOFFICIAL -1 ///< Allow inofficial extensions (deprecated - use FF_COMPLIANCE_UNOFFICIAL instead).
|
||||
#endif
|
||||
#define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions
|
||||
#define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things.
|
||||
|
||||
@@ -1747,6 +1781,25 @@ typedef struct AVCodecContext {
|
||||
*/
|
||||
unsigned dsp_mask;
|
||||
|
||||
#if FF_API_MM_FLAGS
|
||||
#define FF_MM_FORCE AV_CPU_FLAG_FORCE
|
||||
#define FF_MM_MMX AV_CPU_FLAG_MMX
|
||||
#define FF_MM_3DNOW AV_CPU_FLAG_3DNOW
|
||||
#define FF_MM_MMXEXT AV_CPU_FLAG_MMX2
|
||||
#define FF_MM_MMX2 AV_CPU_FLAG_MMX2
|
||||
#define FF_MM_SSE AV_CPU_FLAG_SSE
|
||||
#define FF_MM_SSE2 AV_CPU_FLAG_SSE2
|
||||
#define FF_MM_SSE2SLOW AV_CPU_FLAG_SSE2SLOW
|
||||
#define FF_MM_3DNOWEXT AV_CPU_FLAG_3DNOWEXT
|
||||
#define FF_MM_SSE3 AV_CPU_FLAG_SSE3
|
||||
#define FF_MM_SSE3SLOW AV_CPU_FLAG_SSE3SLOW
|
||||
#define FF_MM_SSSE3 AV_CPU_FLAG_SSSE3
|
||||
#define FF_MM_SSE4 AV_CPU_FLAG_SSE4
|
||||
#define FF_MM_SSE42 AV_CPU_FLAG_SSE42
|
||||
#define FF_MM_IWMMXT AV_CPU_FLAG_IWMMXT
|
||||
#define FF_MM_ALTIVEC AV_CPU_FLAG_ALTIVEC
|
||||
#endif
|
||||
|
||||
/**
|
||||
* bits per sample/pixel from the demuxer (needed for huffyuv).
|
||||
* - encoding: Set by libavcodec.
|
||||
@@ -1821,6 +1874,22 @@ typedef struct AVCodecContext {
|
||||
*/
|
||||
uint64_t error[4];
|
||||
|
||||
#if FF_API_MB_Q
|
||||
/**
|
||||
* minimum MB quantizer
|
||||
* - encoding: unused
|
||||
* - decoding: unused
|
||||
*/
|
||||
attribute_deprecated int mb_qmin;
|
||||
|
||||
/**
|
||||
* maximum MB quantizer
|
||||
* - encoding: unused
|
||||
* - decoding: unused
|
||||
*/
|
||||
attribute_deprecated int mb_qmax;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* motion estimation comparison function
|
||||
* - encoding: Set by user.
|
||||
@@ -2522,6 +2591,23 @@ typedef struct AVCodecContext {
|
||||
int compression_level;
|
||||
#define FF_COMPRESSION_DEFAULT -1
|
||||
|
||||
#if FF_API_USE_LPC
|
||||
/**
|
||||
* Sets whether to use LPC mode - used by FLAC encoder.
|
||||
* - encoding: Set by user.
|
||||
* - decoding: unused
|
||||
* @deprecated Deprecated in favor of lpc_type and lpc_passes.
|
||||
*/
|
||||
int use_lpc;
|
||||
|
||||
/**
|
||||
* LPC coefficient precision - used by FLAC encoder
|
||||
* - encoding: Set by user.
|
||||
* - decoding: unused
|
||||
*/
|
||||
int lpc_coeff_precision;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* - encoding: Set by user.
|
||||
* - decoding: unused
|
||||
@@ -2541,13 +2627,6 @@ typedef struct AVCodecContext {
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* LPC coefficient precision - used by FLAC encoder
|
||||
* - encoding: Set by user.
|
||||
* - decoding: unused
|
||||
*/
|
||||
attribute_deprecated int lpc_coeff_precision;
|
||||
|
||||
/**
|
||||
* search method for selecting prediction order
|
||||
* - encoding: Set by user.
|
||||
@@ -3211,33 +3290,6 @@ int av_dup_packet(AVPacket *pkt);
|
||||
*/
|
||||
void av_free_packet(AVPacket *pkt);
|
||||
|
||||
/**
|
||||
* Allocate new information of a packet.
|
||||
*
|
||||
* @param pkt packet
|
||||
* @param type side information type
|
||||
* @param size side information size
|
||||
* @return pointer to fresh allocated data or NULL otherwise
|
||||
*/
|
||||
uint8_t* av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
|
||||
int size);
|
||||
|
||||
/**
|
||||
* Get side information from packet.
|
||||
*
|
||||
* @param pkt packet
|
||||
* @param type desired side information type
|
||||
* @param size pointer for side information size to store (optional)
|
||||
* @return pointer to data if present or NULL otherwise
|
||||
*/
|
||||
uint8_t* av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
|
||||
int *size);
|
||||
|
||||
int av_packet_merge_side_data(AVPacket *pkt);
|
||||
|
||||
int av_packet_split_side_data(AVPacket *pkt);
|
||||
|
||||
|
||||
/* resample.c */
|
||||
|
||||
struct ReSampleContext;
|
||||
@@ -3245,6 +3297,14 @@ struct AVResampleContext;
|
||||
|
||||
typedef struct ReSampleContext ReSampleContext;
|
||||
|
||||
#if FF_API_AUDIO_OLD
|
||||
/**
|
||||
* @deprecated Use av_audio_resample_init() instead.
|
||||
*/
|
||||
attribute_deprecated ReSampleContext *audio_resample_init(int output_channels, int input_channels,
|
||||
int output_rate, int input_rate);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Initialize audio resampling context.
|
||||
*
|
||||
@@ -3408,6 +3468,23 @@ const char *avcodec_get_pix_fmt_name(enum PixelFormat pix_fmt);
|
||||
|
||||
void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
|
||||
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 53
|
||||
/**
|
||||
* Return the pixel format corresponding to the name name.
|
||||
*
|
||||
* If there is no pixel format with name name, then look for a
|
||||
* pixel format with the name corresponding to the native endian
|
||||
* format of name.
|
||||
* For example in a little-endian system, first look for "gray16",
|
||||
* then for "gray16le".
|
||||
*
|
||||
* Finally if no pixel format has been found, return PIX_FMT_NONE.
|
||||
*
|
||||
* @deprecated Deprecated in favor of av_get_pix_fmt().
|
||||
*/
|
||||
attribute_deprecated enum PixelFormat avcodec_get_pix_fmt(const char* name);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Return a value representing the fourCC code associated to the
|
||||
* pixel format pix_fmt, or 0 if no associated fourCC code can be
|
||||
@@ -3476,6 +3553,14 @@ int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_
|
||||
enum PixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum PixelFormat src_pix_fmt,
|
||||
int has_alpha, int *loss_ptr);
|
||||
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 53
|
||||
/**
|
||||
* @deprecated Use av_get_pix_fmt_string() instead.
|
||||
*/
|
||||
attribute_deprecated
|
||||
void avcodec_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt);
|
||||
#endif
|
||||
|
||||
#define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */
|
||||
#define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */
|
||||
|
||||
@@ -3526,6 +3611,13 @@ const char *avcodec_license(void);
|
||||
*/
|
||||
void avcodec_init(void);
|
||||
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 53
|
||||
/**
|
||||
* @deprecated Deprecated in favor of avcodec_register().
|
||||
*/
|
||||
attribute_deprecated void register_avcodec(AVCodec *codec);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Register the codec codec and initialize libavcodec.
|
||||
*
|
||||
@@ -3670,6 +3762,14 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
|
||||
void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
|
||||
int linesize_align[4]);
|
||||
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 53
|
||||
/**
|
||||
* @deprecated Deprecated in favor of av_check_image_size().
|
||||
*/
|
||||
attribute_deprecated
|
||||
int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h);
|
||||
#endif
|
||||
|
||||
enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
|
||||
|
||||
#if FF_API_THREAD_INIT
|
||||
@@ -3678,13 +3778,12 @@ enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum
|
||||
*/
|
||||
attribute_deprecated
|
||||
int avcodec_thread_init(AVCodecContext *s, int thread_count);
|
||||
void avcodec_thread_free(AVCodecContext *s);
|
||||
#endif
|
||||
|
||||
int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size);
|
||||
int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count);
|
||||
//FIXME func typedef
|
||||
|
||||
#if FF_API_AVCODEC_OPEN
|
||||
/**
|
||||
* Initialize the AVCodecContext to use the given AVCodec. Prior to using this
|
||||
* function the context has to be allocated.
|
||||
@@ -3711,44 +3810,27 @@ int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2,
|
||||
* @param codec The codec to use within the context.
|
||||
* @return zero on success, a negative value on error
|
||||
* @see avcodec_alloc_context, avcodec_find_decoder, avcodec_find_encoder, avcodec_close
|
||||
*
|
||||
* @deprecated use avcodec_open2
|
||||
*/
|
||||
int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
|
||||
#endif
|
||||
|
||||
#if FF_API_AUDIO_OLD
|
||||
/**
|
||||
* Initialize the AVCodecContext to use the given AVCodec. Prior to using this
|
||||
* function the context has to be allocated with avcodec_alloc_context().
|
||||
* Decode an audio frame from buf into samples.
|
||||
* Wrapper function which calls avcodec_decode_audio3.
|
||||
*
|
||||
* The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
|
||||
* avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
|
||||
* retrieving a codec.
|
||||
*
|
||||
* @warning This function is not thread safe!
|
||||
*
|
||||
* @code
|
||||
* avcodec_register_all();
|
||||
* av_dict_set(&opts, "b", "2.5M", 0);
|
||||
* codec = avcodec_find_decoder(CODEC_ID_H264);
|
||||
* if (!codec)
|
||||
* exit(1);
|
||||
*
|
||||
* context = avcodec_alloc_context();
|
||||
*
|
||||
* if (avcodec_open(context, codec, opts) < 0)
|
||||
* exit(1);
|
||||
* @endcode
|
||||
*
|
||||
* @param avctx The context to initialize.
|
||||
* @param options A dictionary filled with AVCodecContext and codec-private options.
|
||||
* On return this object will be filled with options that were not found.
|
||||
*
|
||||
* @return zero on success, a negative value on error
|
||||
* @see avcodec_alloc_context3(), avcodec_find_decoder(), avcodec_find_encoder(),
|
||||
* av_dict_set(), av_opt_find().
|
||||
* @deprecated Use avcodec_decode_audio3 instead.
|
||||
* @param avctx the codec context
|
||||
* @param[out] samples the output buffer
|
||||
* @param[in,out] frame_size_ptr the output buffer size in bytes
|
||||
* @param[in] buf the input buffer
|
||||
* @param[in] buf_size the input buffer size in bytes
|
||||
* @return On error a negative value is returned, otherwise the number of bytes
|
||||
* used or zero if no frame could be decompressed.
|
||||
*/
|
||||
int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options);
|
||||
attribute_deprecated int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples,
|
||||
int *frame_size_ptr,
|
||||
const uint8_t *buf, int buf_size);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Decode the audio frame of size avpkt->size from avpkt->data into samples.
|
||||
@@ -3793,6 +3875,25 @@ int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,
|
||||
int *frame_size_ptr,
|
||||
AVPacket *avpkt);
|
||||
|
||||
#if FF_API_VIDEO_OLD
|
||||
/**
|
||||
* Decode a video frame from buf into picture.
|
||||
* Wrapper function which calls avcodec_decode_video2.
|
||||
*
|
||||
* @deprecated Use avcodec_decode_video2 instead.
|
||||
* @param avctx the codec context
|
||||
* @param[out] picture The AVFrame in which the decoded video frame will be stored.
|
||||
* @param[in] buf the input buffer
|
||||
* @param[in] buf_size the size of the input buffer in bytes
|
||||
* @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero.
|
||||
* @return On error a negative value is returned, otherwise the number of bytes
|
||||
* used or zero if no frame could be decompressed.
|
||||
*/
|
||||
attribute_deprecated int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
|
||||
int *got_picture_ptr,
|
||||
const uint8_t *buf, int buf_size);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Decode the video frame of size avpkt->size from avpkt->data into picture.
|
||||
* Some decoders may support multiple frames in a single AVPacket, such
|
||||
@@ -3837,6 +3938,15 @@ int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
|
||||
int *got_picture_ptr,
|
||||
AVPacket *avpkt);
|
||||
|
||||
#if FF_API_SUBTITLE_OLD
|
||||
/* Decode a subtitle message. Return -1 if error, otherwise return the
|
||||
* number of bytes used. If no subtitle could be decompressed,
|
||||
* got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. */
|
||||
attribute_deprecated int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub,
|
||||
int *got_sub_ptr,
|
||||
const uint8_t *buf, int buf_size);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Decode a subtitle message.
|
||||
* Return a negative value on error, otherwise return the number of bytes used.
|
||||
@@ -4105,6 +4215,15 @@ AVCodecParser *av_parser_next(AVCodecParser *c);
|
||||
void av_register_codec_parser(AVCodecParser *parser);
|
||||
AVCodecParserContext *av_parser_init(int codec_id);
|
||||
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 53
|
||||
attribute_deprecated
|
||||
int av_parser_parse(AVCodecParserContext *s,
|
||||
AVCodecContext *avctx,
|
||||
uint8_t **poutbuf, int *poutbuf_size,
|
||||
const uint8_t *buf, int buf_size,
|
||||
int64_t pts, int64_t dts);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Parse a packet.
|
||||
*
|
||||
@@ -4183,7 +4302,7 @@ AVBitStreamFilter *av_bitstream_filter_next(AVBitStreamFilter *f);
|
||||
*
|
||||
* @see av_realloc
|
||||
*/
|
||||
void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size);
|
||||
void *av_fast_realloc(void *ptr, unsigned int *size, FF_INTERNALC_MEM_TYPE min_size);
|
||||
|
||||
/**
|
||||
* Allocate a buffer, reusing the given one if large enough.
|
||||
@@ -4197,7 +4316,17 @@ void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size);
|
||||
* @param min_size minimum size of *ptr buffer after returning, *ptr will be NULL and
|
||||
* *size 0 if an error occurred.
|
||||
*/
|
||||
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size);
|
||||
void av_fast_malloc(void *ptr, unsigned int *size, FF_INTERNALC_MEM_TYPE min_size);
|
||||
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 53
|
||||
/**
|
||||
* @deprecated Deprecated in favor of av_image_copy().
|
||||
*/
|
||||
attribute_deprecated
|
||||
void av_picture_data_copy(uint8_t *dst_data[4], int dst_linesize[4],
|
||||
uint8_t *src_data[4], int src_linesize[4],
|
||||
enum PixelFormat pix_fmt, int width, int height);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Copy image src to dst. Wraps av_picture_data_copy() above.
|
||||
@@ -4226,6 +4355,22 @@ int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width,
|
||||
*/
|
||||
unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
|
||||
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 53
|
||||
/**
|
||||
* Parse str and put in width_ptr and height_ptr the detected values.
|
||||
*
|
||||
* @deprecated Deprecated in favor of av_parse_video_size().
|
||||
*/
|
||||
attribute_deprecated int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str);
|
||||
|
||||
/**
|
||||
* Parse str and store the detected values in *frame_rate.
|
||||
*
|
||||
* @deprecated Deprecated in favor of av_parse_video_rate().
|
||||
*/
|
||||
attribute_deprecated int av_parse_video_frame_rate(AVRational *frame_rate, const char *str);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Logs a generic warning message about a missing feature. This function is
|
||||
* intended to be used internally by FFmpeg (libavcodec, libavformat, etc.)
|
||||
|
@@ -26,21 +26,12 @@
|
||||
void av_destruct_packet_nofree(AVPacket *pkt)
|
||||
{
|
||||
pkt->data = NULL; pkt->size = 0;
|
||||
pkt->side_data = NULL;
|
||||
pkt->side_data_elems = 0;
|
||||
}
|
||||
|
||||
void av_destruct_packet(AVPacket *pkt)
|
||||
{
|
||||
int i;
|
||||
|
||||
av_free(pkt->data);
|
||||
pkt->data = NULL; pkt->size = 0;
|
||||
|
||||
for (i = 0; i < pkt->side_data_elems; i++)
|
||||
av_free(pkt->side_data[i].data);
|
||||
av_freep(&pkt->side_data);
|
||||
pkt->side_data_elems = 0;
|
||||
}
|
||||
|
||||
void av_init_packet(AVPacket *pkt)
|
||||
@@ -53,8 +44,6 @@ void av_init_packet(AVPacket *pkt)
|
||||
pkt->flags = 0;
|
||||
pkt->stream_index = 0;
|
||||
pkt->destruct= NULL;
|
||||
pkt->side_data = NULL;
|
||||
pkt->side_data_elems = 0;
|
||||
}
|
||||
|
||||
int av_new_packet(AVPacket *pkt, int size)
|
||||
@@ -100,52 +89,23 @@ int av_grow_packet(AVPacket *pkt, int grow_by)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define DUP_DATA(dst, src, size, padding) \
|
||||
do { \
|
||||
void *data; \
|
||||
if (padding) { \
|
||||
if ((unsigned)(size) > (unsigned)(size) + FF_INPUT_BUFFER_PADDING_SIZE) \
|
||||
goto failed_alloc; \
|
||||
data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); \
|
||||
} else { \
|
||||
data = av_malloc(size); \
|
||||
} \
|
||||
if (!data) \
|
||||
goto failed_alloc; \
|
||||
memcpy(data, src, size); \
|
||||
if (padding) \
|
||||
memset((uint8_t*)data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE); \
|
||||
dst = data; \
|
||||
} while(0)
|
||||
|
||||
int av_dup_packet(AVPacket *pkt)
|
||||
{
|
||||
AVPacket tmp_pkt;
|
||||
|
||||
if (((pkt->destruct == av_destruct_packet_nofree) || (pkt->destruct == NULL)) && pkt->data) {
|
||||
tmp_pkt = *pkt;
|
||||
|
||||
pkt->data = NULL;
|
||||
pkt->side_data = NULL;
|
||||
DUP_DATA(pkt->data, tmp_pkt.data, pkt->size, 1);
|
||||
pkt->destruct = av_destruct_packet;
|
||||
|
||||
if (pkt->side_data_elems) {
|
||||
int i;
|
||||
|
||||
DUP_DATA(pkt->side_data, tmp_pkt.side_data,
|
||||
pkt->side_data_elems * sizeof(*pkt->side_data), 0);
|
||||
memset(pkt->side_data, 0, pkt->side_data_elems * sizeof(*pkt->side_data));
|
||||
for (i = 0; i < pkt->side_data_elems; i++) {
|
||||
DUP_DATA(pkt->side_data[i].data, tmp_pkt.side_data[i].data,
|
||||
pkt->side_data[i].size, 1);
|
||||
}
|
||||
uint8_t *data;
|
||||
/* We duplicate the packet and don't forget to add the padding again. */
|
||||
if((unsigned)pkt->size > (unsigned)pkt->size + FF_INPUT_BUFFER_PADDING_SIZE)
|
||||
return AVERROR(ENOMEM);
|
||||
data = av_malloc(pkt->size + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
if (!data) {
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
memcpy(data, pkt->data, pkt->size);
|
||||
memset(data + pkt->size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
pkt->data = data;
|
||||
pkt->destruct = av_destruct_packet;
|
||||
}
|
||||
return 0;
|
||||
failed_alloc:
|
||||
av_destruct_packet(pkt);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
void av_free_packet(AVPacket *pkt)
|
||||
@@ -153,125 +113,6 @@ void av_free_packet(AVPacket *pkt)
|
||||
if (pkt) {
|
||||
if (pkt->destruct) pkt->destruct(pkt);
|
||||
pkt->data = NULL; pkt->size = 0;
|
||||
pkt->side_data = NULL;
|
||||
pkt->side_data_elems = 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t* av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
|
||||
int size)
|
||||
{
|
||||
int elems = pkt->side_data_elems;
|
||||
|
||||
if ((unsigned)elems + 1 > INT_MAX / sizeof(*pkt->side_data))
|
||||
return NULL;
|
||||
if ((unsigned)size > INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE)
|
||||
return NULL;
|
||||
|
||||
pkt->side_data = av_realloc(pkt->side_data, (elems + 1) * sizeof(*pkt->side_data));
|
||||
if (!pkt->side_data)
|
||||
return NULL;
|
||||
|
||||
pkt->side_data[elems].data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
if (!pkt->side_data[elems].data)
|
||||
return NULL;
|
||||
pkt->side_data[elems].size = size;
|
||||
pkt->side_data[elems].type = type;
|
||||
pkt->side_data_elems++;
|
||||
|
||||
return pkt->side_data[elems].data;
|
||||
}
|
||||
|
||||
uint8_t* av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
|
||||
int *size)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < pkt->side_data_elems; i++) {
|
||||
if (pkt->side_data[i].type == type) {
|
||||
if (size)
|
||||
*size = pkt->side_data[i].size;
|
||||
return pkt->side_data[i].data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#define FF_MERGE_MARKER 0x8c4d9d108e25e9feULL
|
||||
|
||||
int av_packet_merge_side_data(AVPacket *pkt){
|
||||
if(pkt->side_data_elems){
|
||||
int i;
|
||||
uint8_t *p;
|
||||
uint64_t size= pkt->size + 8LL + FF_INPUT_BUFFER_PADDING_SIZE;
|
||||
AVPacket old= *pkt;
|
||||
for (i=0; i<old.side_data_elems; i++) {
|
||||
size += old.side_data[i].size + 5LL;
|
||||
}
|
||||
if (size > INT_MAX)
|
||||
return AVERROR(EINVAL);
|
||||
p = av_malloc(size);
|
||||
if (!p)
|
||||
return AVERROR(ENOMEM);
|
||||
pkt->data = p;
|
||||
pkt->destruct = av_destruct_packet;
|
||||
pkt->size = size - FF_INPUT_BUFFER_PADDING_SIZE;
|
||||
bytestream_put_buffer(&p, old.data, old.size);
|
||||
for (i=old.side_data_elems-1; i>=0; i--) {
|
||||
bytestream_put_buffer(&p, old.side_data[i].data, old.side_data[i].size);
|
||||
bytestream_put_be32(&p, old.side_data[i].size);
|
||||
*p++ = old.side_data[i].type | ((i==old.side_data_elems-1)*128);
|
||||
}
|
||||
bytestream_put_be64(&p, FF_MERGE_MARKER);
|
||||
av_assert0(p-pkt->data == pkt->size);
|
||||
memset(p, 0, FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
av_free_packet(&old);
|
||||
pkt->side_data_elems = 0;
|
||||
pkt->side_data = NULL;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int av_packet_split_side_data(AVPacket *pkt){
|
||||
if (!pkt->side_data_elems && pkt->size >12 && AV_RB64(pkt->data + pkt->size - 8) == FF_MERGE_MARKER){
|
||||
int i;
|
||||
unsigned int size;
|
||||
uint8_t *p= pkt->data + pkt->size - 8 - 5;
|
||||
|
||||
av_dup_packet(pkt);
|
||||
|
||||
for (i=1; ; i++){
|
||||
size = AV_RB32(p);
|
||||
if (size>INT_MAX || p - pkt->data <= size)
|
||||
return 0;
|
||||
if (p[4]&128)
|
||||
break;
|
||||
p-= size+5;
|
||||
}
|
||||
|
||||
pkt->side_data = av_malloc(i * sizeof(*pkt->side_data));
|
||||
if (!pkt->side_data)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
p= pkt->data + pkt->size - 8 - 5;
|
||||
for (i=0; ; i++){
|
||||
size= AV_RB32(p);
|
||||
av_assert0(size<=INT_MAX && p - pkt->data > size);
|
||||
pkt->side_data[i].data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
pkt->side_data[i].size = size;
|
||||
pkt->side_data[i].type = p[4]&127;
|
||||
if (!pkt->side_data[i].data)
|
||||
return AVERROR(ENOMEM);
|
||||
memcpy(pkt->side_data[i].data, p-size, size);
|
||||
pkt->size -= size + 5;
|
||||
if(p[4]&128)
|
||||
break;
|
||||
p-= size+5;
|
||||
}
|
||||
pkt->size -= 8;
|
||||
pkt->side_data_elems = i+1;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@@ -457,8 +457,8 @@ static int read_dcs(AVCodecContext *avctx, GetBitContext *gb, Bundle *b,
|
||||
int start_bits, int has_sign)
|
||||
{
|
||||
int i, j, len, len2, bsize, sign, v, v2;
|
||||
int16_t *dst = (int16_t*)b->cur_dec;
|
||||
int16_t *dst_end = (int16_t*)b->data_end;
|
||||
int16_t *dst = (int16_t*)b->cur_dec;
|
||||
int16_t *dst_end =( int16_t*)b->data_end;
|
||||
|
||||
CHECK_READ_VAL(gb, b, len);
|
||||
v = get_bits(gb, start_bits - has_sign);
|
||||
|
@@ -85,9 +85,9 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
frame_len_bits = 11;
|
||||
}
|
||||
|
||||
if (avctx->channels < 1 || avctx->channels > MAX_CHANNELS) {
|
||||
av_log(avctx, AV_LOG_ERROR, "invalid number of channels: %d\n", avctx->channels);
|
||||
return AVERROR_INVALIDDATA;
|
||||
if (avctx->channels > MAX_CHANNELS) {
|
||||
av_log(avctx, AV_LOG_ERROR, "too many channels: %d\n", avctx->channels);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (avctx->extradata && avctx->extradata_size > 0)
|
||||
@@ -153,18 +153,11 @@ static const uint8_t rle_length_tab[16] = {
|
||||
2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 32, 64
|
||||
};
|
||||
|
||||
#define GET_BITS_SAFE(out, nbits) do { \
|
||||
if (get_bits_left(gb) < nbits) \
|
||||
return AVERROR_INVALIDDATA; \
|
||||
out = get_bits(gb, nbits); \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* Decode Bink Audio block
|
||||
* @param[out] out Output buffer (must contain s->block_size elements)
|
||||
* @return 0 on success, negative error code on failure
|
||||
*/
|
||||
static int decode_block(BinkAudioContext *s, short *out, int use_dct)
|
||||
static void decode_block(BinkAudioContext *s, short *out, int use_dct)
|
||||
{
|
||||
int ch, i, j, k;
|
||||
float q, quant[25];
|
||||
@@ -177,19 +170,13 @@ static int decode_block(BinkAudioContext *s, short *out, int use_dct)
|
||||
for (ch = 0; ch < s->channels; ch++) {
|
||||
FFTSample *coeffs = s->coeffs_ptr[ch];
|
||||
if (s->version_b) {
|
||||
if (get_bits_left(gb) < 64)
|
||||
return AVERROR_INVALIDDATA;
|
||||
coeffs[0] = av_int2flt(get_bits(gb, 32)) * s->root;
|
||||
coeffs[1] = av_int2flt(get_bits(gb, 32)) * s->root;
|
||||
} else {
|
||||
if (get_bits_left(gb) < 58)
|
||||
return AVERROR_INVALIDDATA;
|
||||
coeffs[0] = get_float(gb) * s->root;
|
||||
coeffs[1] = get_float(gb) * s->root;
|
||||
}
|
||||
|
||||
if (get_bits_left(gb) < s->num_bands * 8)
|
||||
return AVERROR_INVALIDDATA;
|
||||
for (i = 0; i < s->num_bands; i++) {
|
||||
/* constant is result of 0.066399999/log10(M_E) */
|
||||
int value = get_bits(gb, 8);
|
||||
@@ -204,20 +191,15 @@ static int decode_block(BinkAudioContext *s, short *out, int use_dct)
|
||||
while (i < s->frame_len) {
|
||||
if (s->version_b) {
|
||||
j = i + 16;
|
||||
} else if (get_bits1(gb)) {
|
||||
j = i + rle_length_tab[get_bits(gb, 4)] * 8;
|
||||
} else {
|
||||
int v;
|
||||
GET_BITS_SAFE(v, 1);
|
||||
if (v) {
|
||||
GET_BITS_SAFE(v, 4);
|
||||
j = i + rle_length_tab[v] * 8;
|
||||
} else {
|
||||
j = i + 8;
|
||||
}
|
||||
j = i + 8;
|
||||
}
|
||||
|
||||
j = FFMIN(j, s->frame_len);
|
||||
|
||||
GET_BITS_SAFE(width, 4);
|
||||
width = get_bits(gb, 4);
|
||||
if (width == 0) {
|
||||
memset(coeffs + i, 0, (j - i) * sizeof(*coeffs));
|
||||
i = j;
|
||||
@@ -227,11 +209,9 @@ static int decode_block(BinkAudioContext *s, short *out, int use_dct)
|
||||
while (i < j) {
|
||||
if (s->bands[k] == i)
|
||||
q = quant[k++];
|
||||
GET_BITS_SAFE(coeff, width);
|
||||
coeff = get_bits(gb, width);
|
||||
if (coeff) {
|
||||
int v;
|
||||
GET_BITS_SAFE(v, 1);
|
||||
if (v)
|
||||
if (get_bits1(gb))
|
||||
coeffs[i] = -q * coeff;
|
||||
else
|
||||
coeffs[i] = q * coeff;
|
||||
@@ -267,8 +247,6 @@ static int decode_block(BinkAudioContext *s, short *out, int use_dct)
|
||||
s->overlap_len * s->channels * sizeof(*out));
|
||||
|
||||
s->first = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static av_cold int decode_end(AVCodecContext *avctx)
|
||||
@@ -300,17 +278,12 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
int reported_size;
|
||||
GetBitContext *gb = &s->gb;
|
||||
|
||||
if (buf_size < 4) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
init_get_bits(gb, buf, buf_size * 8);
|
||||
|
||||
reported_size = get_bits_long(gb, 32);
|
||||
while (samples + s->block_size <= samples_end) {
|
||||
if (decode_block(s, samples, avctx->codec->id == CODEC_ID_BINKAUDIO_DCT))
|
||||
break;
|
||||
while (get_bits_count(gb) / 8 < buf_size &&
|
||||
samples + s->block_size <= samples_end) {
|
||||
decode_block(s, samples, avctx->codec->id == CODEC_ID_BINKAUDIO_DCT);
|
||||
samples += s->block_size;
|
||||
get_bits_align32(gb);
|
||||
}
|
||||
|
@@ -280,10 +280,6 @@ static int cdg_decode_frame(AVCodecContext *avctx,
|
||||
av_log(avctx, AV_LOG_ERROR, "buffer too small for decoder\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
if (buf_size > CDG_HEADER_SIZE + CDG_DATA_SIZE) {
|
||||
av_log(avctx, AV_LOG_ERROR, "buffer too big for decoder\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
ret = avctx->reget_buffer(avctx, &cc->frame);
|
||||
if (ret) {
|
||||
|
@@ -133,8 +133,9 @@ void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs,
|
||||
out2 -= val * old_out2;
|
||||
out3 -= val * old_out3;
|
||||
|
||||
old_out3 = out[-5];
|
||||
|
||||
for (i = 5; i <= filter_length; i += 2) {
|
||||
old_out3 = out[-i];
|
||||
val = filter_coeffs[i-1];
|
||||
|
||||
out0 -= val * old_out3;
|
||||
@@ -153,6 +154,7 @@ void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs,
|
||||
|
||||
FFSWAP(float, old_out0, old_out2);
|
||||
old_out1 = old_out3;
|
||||
old_out3 = out[-i-2];
|
||||
}
|
||||
|
||||
tmp0 = out0;
|
||||
|
@@ -67,7 +67,6 @@ typedef struct CinepakContext {
|
||||
|
||||
int sega_film_skip_bytes;
|
||||
|
||||
uint32_t pal[256];
|
||||
} CinepakContext;
|
||||
|
||||
static void cinepak_decode_codebook (cvid_codebook *codebook,
|
||||
@@ -366,8 +365,6 @@ static int cinepak_decode (CinepakContext *s)
|
||||
s->strips[i].x2 = s->avctx->width;
|
||||
|
||||
strip_size = AV_RB24 (&s->data[1]) - 12;
|
||||
if(strip_size < 0)
|
||||
return -1;
|
||||
s->data += 12;
|
||||
strip_size = ((s->data + strip_size) > eod) ? (eod - s->data) : strip_size;
|
||||
|
||||
@@ -399,7 +396,7 @@ static av_cold int cinepak_decode_init(AVCodecContext *avctx)
|
||||
s->sega_film_skip_bytes = -1; /* uninitialized state */
|
||||
|
||||
// check for paletted data
|
||||
if (avctx->bits_per_coded_sample != 8) {
|
||||
if ((avctx->palctrl == NULL) || (avctx->bits_per_coded_sample == 40)) {
|
||||
s->palette_video = 0;
|
||||
avctx->pix_fmt = PIX_FMT_YUV420P;
|
||||
} else {
|
||||
@@ -432,18 +429,16 @@ static int cinepak_decode_frame(AVCodecContext *avctx,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (s->palette_video) {
|
||||
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
|
||||
if (pal) {
|
||||
s->frame.palette_has_changed = 1;
|
||||
memcpy(s->pal, pal, AVPALETTE_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
cinepak_decode(s);
|
||||
|
||||
if (s->palette_video)
|
||||
memcpy (s->frame.data[1], s->pal, AVPALETTE_SIZE);
|
||||
if (s->palette_video) {
|
||||
memcpy (s->frame.data[1], avctx->palctrl->palette, AVPALETTE_SIZE);
|
||||
if (avctx->palctrl->palette_changed) {
|
||||
s->frame.palette_has_changed = 1;
|
||||
avctx->palctrl->palette_changed = 0;
|
||||
} else
|
||||
s->frame.palette_has_changed = 0;
|
||||
}
|
||||
|
||||
*data_size = sizeof(AVFrame);
|
||||
*(AVFrame*)data = s->frame;
|
||||
|
@@ -1066,10 +1066,6 @@ static av_cold int cook_decode_init(AVCodecContext *avctx)
|
||||
q->sample_rate = avctx->sample_rate;
|
||||
q->nb_channels = avctx->channels;
|
||||
q->bit_rate = avctx->bit_rate;
|
||||
if (!q->nb_channels) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid number of channels\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
/* Initialize RNG. */
|
||||
av_lfg_init(&q->random_state, 0);
|
||||
@@ -1083,7 +1079,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx)
|
||||
q->subpacket[s].subbands = bytestream_get_be16(&edata_ptr);
|
||||
extradata_size -= 8;
|
||||
}
|
||||
if (extradata_size >= 8){
|
||||
if (avctx->extradata_size >= 8){
|
||||
bytestream_get_be32(&edata_ptr); //Unknown unused
|
||||
q->subpacket[s].js_subband_start = bytestream_get_be16(&edata_ptr);
|
||||
q->subpacket[s].js_vlc_bits = bytestream_get_be16(&edata_ptr);
|
||||
|
@@ -228,7 +228,7 @@ static av_cold int decode_init(AVCodecContext *avctx) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"CamStudio codec error: invalid depth %i bpp\n",
|
||||
avctx->bits_per_coded_sample);
|
||||
return AVERROR_INVALIDDATA;
|
||||
return 1;
|
||||
}
|
||||
c->bpp = avctx->bits_per_coded_sample;
|
||||
avcodec_get_frame_defaults(&c->pic);
|
||||
@@ -242,7 +242,7 @@ static av_cold int decode_init(AVCodecContext *avctx) {
|
||||
c->decomp_buf = av_malloc(c->decomp_size + AV_LZO_OUTPUT_PADDING);
|
||||
if (!c->decomp_buf) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n");
|
||||
return AVERROR(ENOMEM);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@@ -29,7 +29,6 @@
|
||||
#include "libavutil/common.h"
|
||||
#include "libavutil/intmath.h"
|
||||
#include "libavutil/intreadwrite.h"
|
||||
#include "libavutil/mathematics.h"
|
||||
#include "libavutil/audioconvert.h"
|
||||
#include "avcodec.h"
|
||||
#include "dsputil.h"
|
||||
@@ -906,8 +905,7 @@ static void qmf_32_subbands(DCAContext * s, int chans,
|
||||
for (subindex = 0; subindex < 8; subindex++) {
|
||||
/* Load in one sample from each subband and clear inactive subbands */
|
||||
for (i = 0; i < sb_act; i++){
|
||||
unsigned sign = (i - 1) & 2;
|
||||
uint32_t v = AV_RN32A(&samples_in[i][subindex]) ^ sign << 30;
|
||||
uint32_t v = AV_RN32A(&samples_in[i][subindex]) ^ ((i-1)&2)<<30;
|
||||
AV_WN32A(&s->raXin[i], v);
|
||||
}
|
||||
|
||||
|
@@ -169,7 +169,6 @@ static int dpcm_decode_frame(AVCodecContext *avctx,
|
||||
int in, out = 0;
|
||||
int predictor[2];
|
||||
int channel_number = 0;
|
||||
int stereo = s->channels - 1;
|
||||
short *output_samples = data;
|
||||
int shift[2];
|
||||
unsigned char byte;
|
||||
@@ -178,9 +177,6 @@ static int dpcm_decode_frame(AVCodecContext *avctx,
|
||||
if (!buf_size)
|
||||
return 0;
|
||||
|
||||
if (stereo && (buf_size & 1))
|
||||
buf_size--;
|
||||
|
||||
// almost every DPCM variant expands one byte of data into two
|
||||
if(*data_size/2 < buf_size)
|
||||
return -1;
|
||||
@@ -299,7 +295,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx,
|
||||
}
|
||||
|
||||
*data_size = out * sizeof(short);
|
||||
return avpkt->size;
|
||||
return buf_size;
|
||||
}
|
||||
|
||||
#define DPCM_DECODER(id, name, long_name_) \
|
||||
|
@@ -146,11 +146,11 @@ static int cin_decode_huffman(const unsigned char *src, int src_size, unsigned c
|
||||
return dst_cur - dst;
|
||||
}
|
||||
|
||||
static int cin_decode_lzss(const unsigned char *src, int src_size, unsigned char *dst, int dst_size)
|
||||
static void cin_decode_lzss(const unsigned char *src, int src_size, unsigned char *dst, int dst_size)
|
||||
{
|
||||
uint16_t cmd;
|
||||
int i, sz, offset, code;
|
||||
unsigned char *dst_end = dst + dst_size, *dst_start = dst;
|
||||
unsigned char *dst_end = dst + dst_size;
|
||||
const unsigned char *src_end = src + src_size;
|
||||
|
||||
while (src < src_end && dst < dst_end) {
|
||||
@@ -161,8 +161,6 @@ static int cin_decode_lzss(const unsigned char *src, int src_size, unsigned char
|
||||
} else {
|
||||
cmd = AV_RL16(src); src += 2;
|
||||
offset = cmd >> 4;
|
||||
if ((int) (dst - dst_start) < offset + 1)
|
||||
return AVERROR_INVALIDDATA;
|
||||
sz = (cmd & 0xF) + 2;
|
||||
/* don't use memcpy/memmove here as the decoding routine (ab)uses */
|
||||
/* buffer overlappings to repeat bytes in the destination */
|
||||
@@ -174,8 +172,6 @@ static int cin_decode_lzss(const unsigned char *src, int src_size, unsigned char
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void cin_decode_rle(const unsigned char *src, int src_size, unsigned char *dst, int dst_size)
|
||||
@@ -205,7 +201,13 @@ static int cinvideo_decode_frame(AVCodecContext *avctx,
|
||||
const uint8_t *buf = avpkt->data;
|
||||
int buf_size = avpkt->size;
|
||||
CinVideoContext *cin = avctx->priv_data;
|
||||
int i, y, palette_type, palette_colors_count, bitmap_frame_type, bitmap_frame_size, res = 0;
|
||||
int i, y, palette_type, palette_colors_count, bitmap_frame_type, bitmap_frame_size;
|
||||
|
||||
cin->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
|
||||
if (avctx->reget_buffer(avctx, &cin->frame)) {
|
||||
av_log(cin->avctx, AV_LOG_ERROR, "delphinecinvideo: reget_buffer() failed to allocate a frame\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
palette_type = buf[0];
|
||||
palette_colors_count = AV_RL16(buf+1);
|
||||
@@ -231,6 +233,8 @@ static int cinvideo_decode_frame(AVCodecContext *avctx,
|
||||
bitmap_frame_size -= 4;
|
||||
}
|
||||
}
|
||||
memcpy(cin->frame.data[1], cin->palette, sizeof(cin->palette));
|
||||
cin->frame.palette_has_changed = 1;
|
||||
|
||||
/* note: the decoding routines below assumes that surface.width = surface.pitch */
|
||||
switch (bitmap_frame_type) {
|
||||
@@ -263,31 +267,17 @@ static int cinvideo_decode_frame(AVCodecContext *avctx,
|
||||
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
||||
break;
|
||||
case 38:
|
||||
res = cin_decode_lzss(buf, bitmap_frame_size,
|
||||
cin->bitmap_table[CIN_CUR_BMP],
|
||||
cin->bitmap_size);
|
||||
if (res < 0)
|
||||
return res;
|
||||
cin_decode_lzss(buf, bitmap_frame_size,
|
||||
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
||||
break;
|
||||
case 39:
|
||||
res = cin_decode_lzss(buf, bitmap_frame_size,
|
||||
cin->bitmap_table[CIN_CUR_BMP],
|
||||
cin->bitmap_size);
|
||||
if (res < 0)
|
||||
return res;
|
||||
cin_decode_lzss(buf, bitmap_frame_size,
|
||||
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
||||
cin_apply_delta_data(cin->bitmap_table[CIN_PRE_BMP],
|
||||
cin->bitmap_table[CIN_CUR_BMP], cin->bitmap_size);
|
||||
break;
|
||||
}
|
||||
|
||||
cin->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
|
||||
if (avctx->reget_buffer(avctx, &cin->frame)) {
|
||||
av_log(cin->avctx, AV_LOG_ERROR, "delphinecinvideo: reget_buffer() failed to allocate a frame\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(cin->frame.data[1], cin->palette, sizeof(cin->palette));
|
||||
cin->frame.palette_has_changed = 1;
|
||||
for (y = 0; y < cin->avctx->height; ++y)
|
||||
memcpy(cin->frame.data[0] + (cin->avctx->height - 1 - y) * cin->frame.linesize[0],
|
||||
cin->bitmap_table[CIN_CUR_BMP] + y * cin->avctx->width,
|
||||
@@ -320,11 +310,6 @@ static av_cold int cinaudio_decode_init(AVCodecContext *avctx)
|
||||
CinAudioContext *cin = avctx->priv_data;
|
||||
|
||||
cin->avctx = avctx;
|
||||
if (avctx->channels != 1) {
|
||||
av_log_ask_for_sample(avctx, "Number of channels is not supported\n");
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
|
||||
cin->initial_decode_frame = 1;
|
||||
cin->delta = 0;
|
||||
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
|
||||
|
@@ -120,6 +120,14 @@ void ff_bink_idct_put_c(uint8_t *dest, int linesize, DCTELEM *block);
|
||||
void ff_ea_idct_put_c(uint8_t *dest, int linesize, DCTELEM *block);
|
||||
|
||||
/* 1/2^n downscaling functions from imgconvert.c */
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 53
|
||||
/**
|
||||
* @deprecated Use av_image_copy_plane() instead.
|
||||
*/
|
||||
attribute_deprecated
|
||||
void ff_img_copy_plane(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
|
||||
#endif
|
||||
|
||||
void ff_shrink22(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
|
||||
void ff_shrink44(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
|
||||
void ff_shrink88(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
|
||||
|
@@ -248,13 +248,11 @@ static const DVprofile dv_profiles[] = {
|
||||
const DVprofile* ff_dv_frame_profile(const DVprofile *sys,
|
||||
const uint8_t* frame, unsigned buf_size)
|
||||
{
|
||||
int i, dsf, stype;
|
||||
int i;
|
||||
|
||||
if(buf_size < DV_PROFILE_BYTES)
|
||||
return NULL;
|
||||
int dsf = (frame[3] & 0x80) >> 7;
|
||||
|
||||
dsf = (frame[3] & 0x80) >> 7;
|
||||
stype = frame[80*5 + 48 + 3] & 0x1f;
|
||||
int stype = frame[80*5 + 48 + 3] & 0x1f;
|
||||
|
||||
/* 576i50 25Mbps 4:1:1 is a special case */
|
||||
if (dsf == 1 && stype == 0 && frame[4] & 0x07 /* the APT field */) {
|
||||
|
@@ -85,21 +85,15 @@ static inline void comp_block(MadContext *t, int mb_x, int mb_y,
|
||||
{
|
||||
MpegEncContext *s = &t->s;
|
||||
if (j < 4) {
|
||||
unsigned offset = (mb_y*16 + ((j&2)<<2) + mv_y)*t->last_frame.linesize[0] + mb_x*16 + ((j&1)<<3) + mv_x;
|
||||
if (offset >= (s->height - 7) * t->last_frame.linesize[0] - 7)
|
||||
return;
|
||||
comp(t->frame.data[0] + (mb_y*16 + ((j&2)<<2))*t->frame.linesize[0] + mb_x*16 + ((j&1)<<3),
|
||||
t->frame.linesize[0],
|
||||
t->last_frame.data[0] + offset,
|
||||
t->last_frame.data[0] + (mb_y*16 + ((j&2)<<2) + mv_y)*t->last_frame.linesize[0] + mb_x*16 + ((j&1)<<3) + mv_x,
|
||||
t->last_frame.linesize[0], add);
|
||||
} else if (!(s->avctx->flags & CODEC_FLAG_GRAY)) {
|
||||
int index = j - 3;
|
||||
unsigned offset = (mb_y * 8 + (mv_y/2))*t->last_frame.linesize[index] + mb_x * 8 + (mv_x/2);
|
||||
if (offset >= (s->height/2 - 7) * t->last_frame.linesize[index] - 7)
|
||||
return;
|
||||
comp(t->frame.data[index] + (mb_y*8)*t->frame.linesize[index] + mb_x * 8,
|
||||
t->frame.linesize[index],
|
||||
t->last_frame.data[index] + offset,
|
||||
t->last_frame.data[index] + (mb_y * 8 + (mv_y/2))*t->last_frame.linesize[index] + mb_x * 8 + (mv_x/2),
|
||||
t->last_frame.linesize[index], add);
|
||||
}
|
||||
}
|
||||
@@ -211,8 +205,7 @@ static void decode_mb(MadContext *t, int inter)
|
||||
for (j=0; j<6; j++) {
|
||||
if (mv_map & (1<<j)) { // mv_x and mv_y are guarded by mv_map
|
||||
int add = 2*decode_motion(&s->gb);
|
||||
if (t->last_frame.data[0])
|
||||
comp_block(t, s->mb_x, s->mb_y, j, mv_x, mv_y, add);
|
||||
comp_block(t, s->mb_x, s->mb_y, j, mv_x, mv_y, add);
|
||||
} else {
|
||||
s->dsp.clear_block(t->block);
|
||||
decode_block_intra(t, t->block);
|
||||
@@ -273,8 +266,6 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
avcodec_set_dimensions(avctx, s->width, s->height);
|
||||
if (t->frame.data[0])
|
||||
avctx->release_buffer(avctx, &t->frame);
|
||||
if (t->last_frame.data[0])
|
||||
avctx->release_buffer(avctx, &t->last_frame);
|
||||
}
|
||||
|
||||
t->frame.reference = 1;
|
||||
@@ -289,7 +280,6 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
if (!t->bitstream_buf)
|
||||
return AVERROR(ENOMEM);
|
||||
bswap16_buf(t->bitstream_buf, (const uint16_t*)buf, (buf_end-buf)/2);
|
||||
memset((uint8_t*)t->bitstream_buf + (buf_end-buf), 0, FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
init_get_bits(&s->gb, t->bitstream_buf, 8*(buf_end-buf));
|
||||
|
||||
for (s->mb_y=0; s->mb_y < (avctx->height+15)/16; s->mb_y++)
|
||||
|
@@ -74,7 +74,7 @@ static int unpack(const uint8_t *src, const uint8_t *src_end, unsigned char *dst
|
||||
else
|
||||
src += 2;
|
||||
|
||||
if (src_end - src < 3)
|
||||
if (src+3>src_end)
|
||||
return -1;
|
||||
size = AV_RB24(src);
|
||||
src += 3;
|
||||
@@ -138,7 +138,7 @@ static int unpack(const uint8_t *src, const uint8_t *src_end, unsigned char *dst
|
||||
* @return 0 on success, -1 on critical buffer underflow
|
||||
*/
|
||||
static int tgv_decode_inter(TgvContext * s, const uint8_t *buf, const uint8_t *buf_end){
|
||||
unsigned last_frame_size = s->avctx->height*s->last_frame.linesize[0];
|
||||
unsigned char *frame0_end = s->last_frame.data[0] + s->avctx->width*s->last_frame.linesize[0];
|
||||
int num_mvs;
|
||||
int num_blocks_raw;
|
||||
int num_blocks_packed;
|
||||
@@ -148,7 +148,7 @@ static int tgv_decode_inter(TgvContext * s, const uint8_t *buf, const uint8_t *b
|
||||
int mvbits;
|
||||
const unsigned char *blocks_raw;
|
||||
|
||||
if(buf_end - buf < 12)
|
||||
if(buf+12>buf_end)
|
||||
return -1;
|
||||
|
||||
num_mvs = AV_RL16(&buf[0]);
|
||||
@@ -171,7 +171,7 @@ static int tgv_decode_inter(TgvContext * s, const uint8_t *buf, const uint8_t *b
|
||||
/* read motion vectors */
|
||||
mvbits = (num_mvs*2*10+31) & ~31;
|
||||
|
||||
if (buf_end - buf < (mvbits>>3)+16*num_blocks_raw+8*num_blocks_packed)
|
||||
if (buf+(mvbits>>3)+16*num_blocks_raw+8*num_blocks_packed>buf_end)
|
||||
return -1;
|
||||
|
||||
init_get_bits(&gb, buf, mvbits);
|
||||
@@ -207,14 +207,12 @@ static int tgv_decode_inter(TgvContext * s, const uint8_t *buf, const uint8_t *b
|
||||
int src_stride;
|
||||
|
||||
if (vector < num_mvs) {
|
||||
unsigned offset =
|
||||
(y*4 + s->mv_codebook[vector][1])*s->last_frame.linesize[0] +
|
||||
x*4 + s->mv_codebook[vector][0];
|
||||
|
||||
src = s->last_frame.data[0] +
|
||||
(y*4 + s->mv_codebook[vector][1])*s->last_frame.linesize[0] +
|
||||
x*4 + s->mv_codebook[vector][0];
|
||||
src_stride = s->last_frame.linesize[0];
|
||||
if (offset >= last_frame_size - (3*src_stride+3))
|
||||
if (src+3*src_stride+3>=frame0_end)
|
||||
continue;
|
||||
src = s->last_frame.data[0] + offset;
|
||||
}else{
|
||||
int offset = vector - num_mvs;
|
||||
if (offset<num_blocks_raw)
|
||||
@@ -254,15 +252,12 @@ static int tgv_decode_frame(AVCodecContext *avctx,
|
||||
const uint8_t *buf_end = buf + buf_size;
|
||||
int chunk_type;
|
||||
|
||||
if (buf_end - buf < EA_PREAMBLE_SIZE)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
chunk_type = AV_RL32(&buf[0]);
|
||||
buf += EA_PREAMBLE_SIZE;
|
||||
|
||||
if (chunk_type==kVGT_TAG) {
|
||||
int pal_count, i;
|
||||
if(buf_end - buf < 12) {
|
||||
if(buf+12>buf_end) {
|
||||
av_log(avctx, AV_LOG_WARNING, "truncated header\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -277,7 +272,7 @@ static int tgv_decode_frame(AVCodecContext *avctx,
|
||||
|
||||
pal_count = AV_RL16(&buf[6]);
|
||||
buf += 12;
|
||||
for(i=0; i<pal_count && i<AVPALETTE_COUNT && buf_end - buf >= 3; i++) {
|
||||
for(i=0; i<pal_count && i<AVPALETTE_COUNT && buf+2<buf_end; i++) {
|
||||
s->palette[i] = AV_RB24(buf);
|
||||
buf += 3;
|
||||
}
|
||||
|
@@ -59,15 +59,12 @@ static av_cold int tqi_decode_init(AVCodecContext *avctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tqi_decode_mb(MpegEncContext *s, DCTELEM (*block)[64])
|
||||
static void tqi_decode_mb(MpegEncContext *s, DCTELEM (*block)[64])
|
||||
{
|
||||
int n;
|
||||
s->dsp.clear_blocks(block[0]);
|
||||
for (n=0; n<6; n++)
|
||||
if (ff_mpeg1_decode_block_intra(s, block[n], n) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
ff_mpeg1_decode_block_intra(s, block[n], n);
|
||||
}
|
||||
|
||||
static inline void tqi_idct_put(TqiContext *t, DCTELEM (*block)[64])
|
||||
@@ -139,8 +136,7 @@ static int tqi_decode_frame(AVCodecContext *avctx,
|
||||
for (s->mb_y=0; s->mb_y<(avctx->height+15)/16; s->mb_y++)
|
||||
for (s->mb_x=0; s->mb_x<(avctx->width+15)/16; s->mb_x++)
|
||||
{
|
||||
if (tqi_decode_mb(s, t->block) < 0)
|
||||
break;
|
||||
tqi_decode_mb(s, t->block);
|
||||
tqi_idct_put(t, t->block);
|
||||
}
|
||||
|
||||
|
@@ -420,16 +420,7 @@ static inline int decode_subframe(FLACContext *s, int channel)
|
||||
type = get_bits(&s->gb, 6);
|
||||
|
||||
if (get_bits1(&s->gb)) {
|
||||
int left = get_bits_left(&s->gb);
|
||||
wasted = 1;
|
||||
if ( left < 0 ||
|
||||
(left < s->curr_bps && !show_bits_long(&s->gb, left)) ||
|
||||
!show_bits_long(&s->gb, s->curr_bps)) {
|
||||
av_log(s->avctx, AV_LOG_ERROR,
|
||||
"Invalid number of wasted bits > available bits (%d) - left=%d\n",
|
||||
s->curr_bps, left);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
while (!get_bits1(&s->gb))
|
||||
wasted++;
|
||||
s->curr_bps -= wasted;
|
||||
|
@@ -296,6 +296,17 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
|
||||
s->options.max_partition_order = ((int[]){ 2, 2, 3, 3, 3, 8, 8, 8, 8, 8, 8, 8, 8})[level];
|
||||
|
||||
/* set compression option overrides from AVCodecContext */
|
||||
#if FF_API_USE_LPC
|
||||
/* for compatibility with deprecated AVCodecContext.use_lpc */
|
||||
if (avctx->use_lpc == 0) {
|
||||
s->options.lpc_type = AV_LPC_TYPE_FIXED;
|
||||
} else if (avctx->use_lpc == 1) {
|
||||
s->options.lpc_type = AV_LPC_TYPE_LEVINSON;
|
||||
} else if (avctx->use_lpc > 1) {
|
||||
s->options.lpc_type = AV_LPC_TYPE_CHOLESKY;
|
||||
s->options.lpc_passes = avctx->use_lpc - 1;
|
||||
}
|
||||
#endif
|
||||
#if FF_API_FLAC_GLOBAL_OPTS
|
||||
if (avctx->lpc_type > FF_LPC_TYPE_DEFAULT) {
|
||||
if (avctx->lpc_type > FF_LPC_TYPE_CHOLESKY) {
|
||||
|
@@ -135,7 +135,7 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
uint32_t *luma1,*luma2,*cb,*cr;
|
||||
uint32_t offs[4];
|
||||
int i, j, is_chroma, planes;
|
||||
enum PixelFormat pix_fmt;
|
||||
|
||||
|
||||
header = AV_RL32(buf);
|
||||
version = header & 0xff;
|
||||
@@ -152,16 +152,12 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
if (header_size == 8)
|
||||
buf+=4;
|
||||
|
||||
pix_fmt = version & 1 ? PIX_FMT_BGR24 : PIX_FMT_YUVJ420P;
|
||||
if (avctx->pix_fmt != pix_fmt && f->data[0]) {
|
||||
avctx->release_buffer(avctx, f);
|
||||
}
|
||||
avctx->pix_fmt = pix_fmt;
|
||||
|
||||
switch(version) {
|
||||
case 0:
|
||||
default:
|
||||
/* Fraps v0 is a reordered YUV420 */
|
||||
avctx->pix_fmt = PIX_FMT_YUVJ420P;
|
||||
|
||||
if ( (buf_size != avctx->width*avctx->height*3/2+header_size) &&
|
||||
(buf_size != header_size) ) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
@@ -209,6 +205,8 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
|
||||
case 1:
|
||||
/* Fraps v1 is an upside-down BGR24 */
|
||||
avctx->pix_fmt = PIX_FMT_BGR24;
|
||||
|
||||
if ( (buf_size != avctx->width*avctx->height*3+header_size) &&
|
||||
(buf_size != header_size) ) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
@@ -243,6 +241,7 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
* Fraps v2 is Huffman-coded YUV420 planes
|
||||
* Fraps v4 is virtually the same
|
||||
*/
|
||||
avctx->pix_fmt = PIX_FMT_YUVJ420P;
|
||||
planes = 3;
|
||||
f->reference = 1;
|
||||
f->buffer_hints = FF_BUFFER_HINTS_VALID |
|
||||
@@ -287,6 +286,7 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
case 3:
|
||||
case 5:
|
||||
/* Virtually the same as version 4, but is for RGB24 */
|
||||
avctx->pix_fmt = PIX_FMT_BGR24;
|
||||
planes = 3;
|
||||
f->reference = 1;
|
||||
f->buffer_hints = FF_BUFFER_HINTS_VALID |
|
||||
|
@@ -75,20 +75,6 @@ static inline int get_ue_golomb(GetBitContext *gb){
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read an unsigned Exp-Golomb code in the range 0 to UINT32_MAX-1.
|
||||
*/
|
||||
static inline unsigned get_ue_golomb_long(GetBitContext *gb)
|
||||
{
|
||||
unsigned buf, log;
|
||||
|
||||
buf = show_bits_long(gb, 32);
|
||||
log = 31 - av_log2(buf);
|
||||
skip_bits_long(gb, log);
|
||||
|
||||
return get_bits_long(gb, log + 1) - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* read unsigned exp golomb code, constraint to a max of 31.
|
||||
* the return value is undefined if the stored value exceeds 31.
|
||||
@@ -123,7 +109,7 @@ static inline int svq3_get_ue_golomb(GetBitContext *gb){
|
||||
}else{
|
||||
int ret = 1;
|
||||
|
||||
do {
|
||||
while (1) {
|
||||
buf >>= 32 - 8;
|
||||
LAST_SKIP_BITS(re, gb, FFMIN(ff_interleaved_golomb_vlc_len[buf], 8));
|
||||
|
||||
@@ -135,7 +121,7 @@ static inline int svq3_get_ue_golomb(GetBitContext *gb){
|
||||
ret = (ret << 4) | ff_interleaved_dirac_golomb_vlc_code[buf];
|
||||
UPDATE_CACHE(re, gb);
|
||||
buf = GET_CACHE(re, gb);
|
||||
} while (ret);
|
||||
}
|
||||
|
||||
CLOSE_READER(re, gb);
|
||||
return ret - 1;
|
||||
@@ -301,7 +287,7 @@ static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit, int
|
||||
return buf;
|
||||
}else{
|
||||
int i;
|
||||
for (i = 0; i < limit && SHOW_UBITS(re, gb, 1) == 0; i++) {
|
||||
for(i=0; SHOW_UBITS(re, gb, 1) == 0; i++){
|
||||
LAST_SKIP_BITS(re, gb, 1);
|
||||
UPDATE_CACHE(re, gb);
|
||||
}
|
||||
|
@@ -599,6 +599,10 @@ retry:
|
||||
s->current_picture.pict_type= s->pict_type;
|
||||
s->current_picture.key_frame= s->pict_type == AV_PICTURE_TYPE_I;
|
||||
|
||||
#if FF_API_HURRY_UP
|
||||
/* skip everything if we are in a hurry>=5 */
|
||||
if(avctx->hurry_up>=5) return get_consumed_bytes(s, buf_size);
|
||||
#endif
|
||||
if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==AV_PICTURE_TYPE_B)
|
||||
||(avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=AV_PICTURE_TYPE_I)
|
||||
|| avctx->skip_frame >= AVDISCARD_ALL)
|
||||
|
@@ -438,13 +438,6 @@ retry:
|
||||
if (ret < 0){
|
||||
av_log(s->avctx, AV_LOG_ERROR, "header damaged\n");
|
||||
return -1;
|
||||
} else if ((s->width != avctx->coded_width ||
|
||||
s->height != avctx->coded_height ||
|
||||
(s->width + 15) >> 4 != s->mb_width ||
|
||||
(s->height + 15) >> 4 != s->mb_height) &&
|
||||
(HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME))) {
|
||||
av_log_missing_feature(s->avctx, "Width/height/bit depth/chroma idc changing with threads is", 0);
|
||||
return AVERROR_PATCHWELCOME; // width / height changed during parallelized decoding
|
||||
}
|
||||
|
||||
avctx->has_b_frames= !s->low_delay;
|
||||
@@ -571,7 +564,8 @@ retry:
|
||||
#if HAVE_MMX
|
||||
if (s->codec_id == CODEC_ID_MPEG4 && s->xvid_build>=0 && avctx->idct_algo == FF_IDCT_AUTO && (av_get_cpu_flags() & AV_CPU_FLAG_MMX)) {
|
||||
avctx->idct_algo= FF_IDCT_XVIDMMX;
|
||||
ff_dct_common_init(s);
|
||||
avctx->coded_width= 0; // force reinit
|
||||
// dsputil_init(&s->dsp, avctx);
|
||||
s->picture_number=0;
|
||||
}
|
||||
#endif
|
||||
@@ -585,12 +579,6 @@ retry:
|
||||
|| s->height != avctx->coded_height) {
|
||||
/* H.263 could change picture size any time */
|
||||
ParseContext pc= s->parse_context; //FIXME move these demuxng hack to avformat
|
||||
|
||||
if (HAVE_THREADS && (s->avctx->active_thread_type&FF_THREAD_FRAME)) {
|
||||
av_log_missing_feature(s->avctx, "Width/height/bit depth/chroma idc changing with threads is", 0);
|
||||
return -1; // width / height changed during parallelized decoding
|
||||
}
|
||||
|
||||
s->parse_context.buffer=0;
|
||||
MPV_common_end(s);
|
||||
s->parse_context= pc;
|
||||
@@ -610,10 +598,18 @@ retry:
|
||||
|
||||
/* skip B-frames if we don't have reference frames */
|
||||
if(s->last_picture_ptr==NULL && (s->pict_type==AV_PICTURE_TYPE_B || s->dropable)) return get_consumed_bytes(s, buf_size);
|
||||
#if FF_API_HURRY_UP
|
||||
/* skip b frames if we are in a hurry */
|
||||
if(avctx->hurry_up && s->pict_type==FF_B_TYPE) return get_consumed_bytes(s, buf_size);
|
||||
#endif
|
||||
if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==AV_PICTURE_TYPE_B)
|
||||
|| (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=AV_PICTURE_TYPE_I)
|
||||
|| avctx->skip_frame >= AVDISCARD_ALL)
|
||||
return get_consumed_bytes(s, buf_size);
|
||||
#if FF_API_HURRY_UP
|
||||
/* skip everything if we are in a hurry>=5 */
|
||||
if(avctx->hurry_up>=5) return get_consumed_bytes(s, buf_size);
|
||||
#endif
|
||||
|
||||
if(s->next_p_frame_damaged){
|
||||
if(s->pict_type==AV_PICTURE_TYPE_B)
|
||||
|
@@ -108,10 +108,7 @@ int ff_h264_check_intra4x4_pred_mode(H264Context *h){
|
||||
return 0;
|
||||
} //FIXME cleanup like check_intra_pred_mode
|
||||
|
||||
/**
|
||||
* checks if the top & left blocks are available if needed & changes the dc mode so it only uses the available blocks.
|
||||
*/
|
||||
int ff_h264_check_intra_pred_mode(H264Context *h, int mode, int is_chroma){
|
||||
static int check_intra_pred_mode(H264Context *h, int mode, int is_chroma){
|
||||
MpegEncContext * const s = &h->s;
|
||||
static const int8_t top [7]= {LEFT_DC_PRED8x8, 1,-1,-1};
|
||||
static const int8_t left[7]= { TOP_DC_PRED8x8,-1, 2,-1,DC_128_PRED8x8};
|
||||
@@ -143,6 +140,23 @@ int ff_h264_check_intra_pred_mode(H264Context *h, int mode, int is_chroma){
|
||||
return mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if the top & left blocks are available if needed & changes the dc mode so it only uses the available blocks.
|
||||
*/
|
||||
int ff_h264_check_intra16x16_pred_mode(H264Context *h, int mode)
|
||||
{
|
||||
return check_intra_pred_mode(h, mode, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if the top & left blocks are available if needed & changes the dc mode so it only uses the available blocks.
|
||||
*/
|
||||
int ff_h264_check_intra_chroma_pred_mode(H264Context *h, int mode)
|
||||
{
|
||||
return check_intra_pred_mode(h, mode, 1);
|
||||
}
|
||||
|
||||
|
||||
const uint8_t *ff_h264_decode_nal(H264Context *h, const uint8_t *src, int *dst_length, int *consumed, int length){
|
||||
int i, si, di;
|
||||
uint8_t *dst;
|
||||
@@ -1005,12 +1019,8 @@ static av_cold void common_init(H264Context *h){
|
||||
s->height = s->avctx->height;
|
||||
s->codec_id= s->avctx->codec->id;
|
||||
|
||||
s->avctx->bits_per_raw_sample = 8;
|
||||
|
||||
ff_h264dsp_init(&h->h264dsp,
|
||||
s->avctx->bits_per_raw_sample);
|
||||
ff_h264_pred_init(&h->hpc, s->codec_id,
|
||||
s->avctx->bits_per_raw_sample);
|
||||
ff_h264dsp_init(&h->h264dsp, 8);
|
||||
ff_h264_pred_init(&h->hpc, s->codec_id, 8);
|
||||
|
||||
h->dequant_coeff_pps= -1;
|
||||
s->unrestricted_mv=1;
|
||||
@@ -2217,11 +2227,7 @@ static void implicit_weight_table(H264Context *h, int field){
|
||||
}
|
||||
|
||||
if(field < 0){
|
||||
if (s->picture_structure == PICT_FRAME) {
|
||||
cur_poc = s->current_picture_ptr->poc;
|
||||
} else {
|
||||
cur_poc = s->current_picture_ptr->field_poc[s->picture_structure - 1];
|
||||
}
|
||||
cur_poc = s->current_picture_ptr->poc;
|
||||
if( h->ref_count[0] == 1 && h->ref_count[1] == 1 && !FRAME_MBAFF
|
||||
&& h->ref_list[0][0].poc + h->ref_list[1][0].poc == 2*cur_poc){
|
||||
h->use_weight= 0;
|
||||
@@ -2620,14 +2626,13 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
|
||||
if (s->context_initialized
|
||||
&& ( s->width != s->avctx->width || s->height != s->avctx->height
|
||||
|| av_cmp_q(h->sps.sar, s->avctx->sample_aspect_ratio))) {
|
||||
if(h != h0 || (HAVE_THREADS && h->s.avctx->active_thread_type & FF_THREAD_FRAME)) {
|
||||
if(h != h0) {
|
||||
av_log_missing_feature(s->avctx, "Width/height changing with threads is", 0);
|
||||
return AVERROR_PATCHWELCOME; // width / height changed during parallelized decoding
|
||||
return -1; // width / height changed during parallelized decoding
|
||||
}
|
||||
free_tables(h, 0);
|
||||
flush_dpb(s->avctx);
|
||||
MPV_common_end(s);
|
||||
h->list_count = 0;
|
||||
}
|
||||
if (!s->context_initialized) {
|
||||
if (h != h0) {
|
||||
@@ -2800,9 +2805,11 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
|
||||
s0->first_field = FIELD_PICTURE;
|
||||
|
||||
} else {
|
||||
if (s0->current_picture_ptr->frame_num != h->frame_num) {
|
||||
if (h->nal_ref_idc &&
|
||||
s0->current_picture_ptr->reference &&
|
||||
s0->current_picture_ptr->frame_num != h->frame_num) {
|
||||
/*
|
||||
* This and previous field had
|
||||
* This and previous field were reference, but had
|
||||
* different frame_nums. Consider this field first in
|
||||
* pair. Throw away previous field except for reference
|
||||
* purposes.
|
||||
@@ -2886,8 +2893,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
|
||||
h->ref_count[1]= h->pps.ref_count[1];
|
||||
|
||||
if(h->slice_type_nos != AV_PICTURE_TYPE_I){
|
||||
unsigned max= s->picture_structure == PICT_FRAME ? 15 : 31;
|
||||
|
||||
unsigned max= (16<<(s->picture_structure != PICT_FRAME))-1;
|
||||
if(h->slice_type_nos == AV_PICTURE_TYPE_B){
|
||||
h->direct_spatial_mv_pred= get_bits1(&s->gb);
|
||||
}
|
||||
@@ -2897,14 +2903,13 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
|
||||
h->ref_count[0]= get_ue_golomb(&s->gb) + 1;
|
||||
if(h->slice_type_nos==AV_PICTURE_TYPE_B)
|
||||
h->ref_count[1]= get_ue_golomb(&s->gb) + 1;
|
||||
}
|
||||
|
||||
if (h->ref_count[0]-1 > max || h->ref_count[1]-1 > max){
|
||||
}
|
||||
if(h->ref_count[0]-1 > max || h->ref_count[1]-1 > max){
|
||||
av_log(h->s.avctx, AV_LOG_ERROR, "reference overflow\n");
|
||||
h->ref_count[0] = h->ref_count[1] = 1;
|
||||
return AVERROR_INVALIDDATA;
|
||||
h->ref_count[0]= h->ref_count[1]= 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(h->slice_type_nos == AV_PICTURE_TYPE_B)
|
||||
h->list_count= 2;
|
||||
else
|
||||
@@ -3748,19 +3753,19 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
|
||||
switch (hx->nal_unit_type) {
|
||||
case NAL_SPS:
|
||||
case NAL_PPS:
|
||||
nals_needed = nal_index;
|
||||
break;
|
||||
case NAL_IDR_SLICE:
|
||||
case NAL_SLICE:
|
||||
init_get_bits(&hx->s.gb, ptr, bit_length);
|
||||
if (!get_ue_golomb(&hx->s.gb))
|
||||
nals_needed = nal_index;
|
||||
nals_needed = nal_index;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
//FIXME do not discard SEI id
|
||||
if(avctx->skip_frame >= AVDISCARD_NONREF && h->nal_ref_idc == 0)
|
||||
if(
|
||||
#if FF_API_HURRY_UP
|
||||
(s->hurry_up == 1 && h->nal_ref_idc == 0) ||
|
||||
#endif
|
||||
(avctx->skip_frame >= AVDISCARD_NONREF && h->nal_ref_idc == 0))
|
||||
continue;
|
||||
|
||||
again:
|
||||
@@ -3797,6 +3802,9 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
|
||||
}
|
||||
|
||||
if(hx->redundant_pic_count==0
|
||||
#if FF_API_HURRY_UP
|
||||
&& hx->s.hurry_up < 5
|
||||
#endif
|
||||
&& (avctx->skip_frame < AVDISCARD_NONREF || hx->nal_ref_idc)
|
||||
&& (avctx->skip_frame < AVDISCARD_BIDIR || hx->slice_type_nos!=AV_PICTURE_TYPE_B)
|
||||
&& (avctx->skip_frame < AVDISCARD_NONKEY || hx->slice_type_nos==AV_PICTURE_TYPE_I)
|
||||
@@ -3834,6 +3842,9 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
|
||||
|
||||
if(hx->redundant_pic_count==0 && hx->intra_gb_ptr && hx->s.data_partitioning
|
||||
&& s->context_initialized
|
||||
#if FF_API_HURRY_UP
|
||||
&& s->hurry_up < 5
|
||||
#endif
|
||||
&& (avctx->skip_frame < AVDISCARD_NONREF || hx->nal_ref_idc)
|
||||
&& (avctx->skip_frame < AVDISCARD_BIDIR || hx->slice_type_nos!=AV_PICTURE_TYPE_B)
|
||||
&& (avctx->skip_frame < AVDISCARD_NONKEY || hx->slice_type_nos==AV_PICTURE_TYPE_I)
|
||||
@@ -3972,7 +3983,11 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
}
|
||||
|
||||
if(!(s->flags2 & CODEC_FLAG2_CHUNKS) && !s->current_picture_ptr){
|
||||
if (avctx->skip_frame >= AVDISCARD_NONREF)
|
||||
if (avctx->skip_frame >= AVDISCARD_NONREF
|
||||
#if FF_API_HURRY_UP
|
||||
|| s->hurry_up
|
||||
#endif
|
||||
)
|
||||
return 0;
|
||||
av_log(avctx, AV_LOG_ERROR, "no frame!\n");
|
||||
return -1;
|
||||
|
@@ -227,7 +227,7 @@ typedef struct PPS{
|
||||
int transform_8x8_mode; ///< transform_8x8_mode_flag
|
||||
uint8_t scaling_matrix4[6][16];
|
||||
uint8_t scaling_matrix8[6][64];
|
||||
uint8_t chroma_qp_table[2][QP_MAX_NUM+1]; ///< pre-scaled (with chroma_qp_index_offset) version of qp_table
|
||||
uint8_t chroma_qp_table[2][64]; ///< pre-scaled (with chroma_qp_index_offset) version of qp_table
|
||||
int chroma_qp_diff;
|
||||
}PPS;
|
||||
|
||||
@@ -658,7 +658,12 @@ int ff_h264_check_intra4x4_pred_mode(H264Context *h);
|
||||
/**
|
||||
* Check if the top & left blocks are available if needed & change the dc mode so it only uses the available blocks.
|
||||
*/
|
||||
int ff_h264_check_intra_pred_mode(H264Context *h, int mode, int is_chroma);
|
||||
int ff_h264_check_intra16x16_pred_mode(H264Context *h, int mode);
|
||||
|
||||
/**
|
||||
* Check if the top & left blocks are available if needed & change the dc mode so it only uses the available blocks.
|
||||
*/
|
||||
int ff_h264_check_intra_chroma_pred_mode(H264Context *h, int mode);
|
||||
|
||||
void ff_h264_write_back_intra_pred_mode(H264Context *h);
|
||||
void ff_h264_hl_decode_mb(H264Context *h);
|
||||
@@ -1070,7 +1075,7 @@ static void fill_decode_caches(H264Context *h, int mb_type){
|
||||
AV_ZERO32(h->mv_cache [list][scan8[0] + 4 - 1*8]);
|
||||
h->ref_cache[list][scan8[0] + 4 - 1*8]= topright_type ? LIST_NOT_USED : PART_NOT_AVAILABLE;
|
||||
}
|
||||
if(h->ref_cache[list][scan8[0] + 2 - 1*8] < 0 || h->ref_cache[list][scan8[0] + 4 - 1*8] < 0){
|
||||
if(h->ref_cache[list][scan8[0] + 4 - 1*8] < 0){
|
||||
if(USES_LIST(topleft_type, list)){
|
||||
const int b_xy = h->mb2b_xy [topleft_xy] + 3 + h->b_stride + (h->topleft_partition & 2*h->b_stride);
|
||||
const int b8_xy= 4*topleft_xy + 1 + (h->topleft_partition & 2);
|
||||
|
@@ -1959,8 +1959,6 @@ decode_intra_mb:
|
||||
}
|
||||
|
||||
// The pixels are stored in the same order as levels in h->mb array.
|
||||
if ((int) (h->cabac.bytestream_end - ptr) < mb_size)
|
||||
return -1;
|
||||
memcpy(h->mb, ptr, mb_size); ptr+=mb_size;
|
||||
|
||||
ff_init_cabac_decoder(&h->cabac, ptr, h->cabac.bytestream_end - ptr);
|
||||
@@ -2005,14 +2003,14 @@ decode_intra_mb:
|
||||
ff_h264_write_back_intra_pred_mode(h);
|
||||
if( ff_h264_check_intra4x4_pred_mode(h) < 0 ) return -1;
|
||||
} else {
|
||||
h->intra16x16_pred_mode= ff_h264_check_intra_pred_mode( h, h->intra16x16_pred_mode, 0 );
|
||||
h->intra16x16_pred_mode= ff_h264_check_intra16x16_pred_mode( h, h->intra16x16_pred_mode );
|
||||
if( h->intra16x16_pred_mode < 0 ) return -1;
|
||||
}
|
||||
if(decode_chroma){
|
||||
h->chroma_pred_mode_table[mb_xy] =
|
||||
pred_mode = decode_cabac_mb_chroma_pre_mode( h );
|
||||
|
||||
pred_mode= ff_h264_check_intra_pred_mode( h, pred_mode, 1 );
|
||||
pred_mode= ff_h264_check_intra_chroma_pred_mode( h, pred_mode );
|
||||
if( pred_mode < 0 ) return -1;
|
||||
h->chroma_pred_mode= pred_mode;
|
||||
} else {
|
||||
|
@@ -238,18 +238,17 @@ static inline int pred_non_zero_count(H264Context *h, int n){
|
||||
}
|
||||
|
||||
static av_cold void init_cavlc_level_tab(void){
|
||||
int suffix_length;
|
||||
int suffix_length, mask;
|
||||
unsigned int i;
|
||||
|
||||
for(suffix_length=0; suffix_length<7; suffix_length++){
|
||||
for(i=0; i<(1<<LEVEL_TAB_BITS); i++){
|
||||
int prefix= LEVEL_TAB_BITS - av_log2(2*i);
|
||||
int level_code= (prefix<<suffix_length) + (i>>(LEVEL_TAB_BITS-prefix-1-suffix_length)) - (1<<suffix_length);
|
||||
|
||||
mask= -(level_code&1);
|
||||
level_code= (((2+level_code)>>1) ^ mask) - mask;
|
||||
if(prefix + 1 + suffix_length <= LEVEL_TAB_BITS){
|
||||
int level_code = (prefix << suffix_length) +
|
||||
(i >> (av_log2(i) - suffix_length)) - (1 << suffix_length);
|
||||
int mask = -(level_code&1);
|
||||
level_code = (((2 + level_code) >> 1) ^ mask) - mask;
|
||||
cavlc_level_tab[suffix_length][i][0]= level_code;
|
||||
cavlc_level_tab[suffix_length][i][1]= prefix + 1 + suffix_length;
|
||||
}else if(prefix + 1 <= LEVEL_TAB_BITS){
|
||||
@@ -736,12 +735,12 @@ decode_intra_mb:
|
||||
if( ff_h264_check_intra4x4_pred_mode(h) < 0)
|
||||
return -1;
|
||||
}else{
|
||||
h->intra16x16_pred_mode= ff_h264_check_intra_pred_mode(h, h->intra16x16_pred_mode, 0);
|
||||
h->intra16x16_pred_mode= ff_h264_check_intra16x16_pred_mode(h, h->intra16x16_pred_mode);
|
||||
if(h->intra16x16_pred_mode < 0)
|
||||
return -1;
|
||||
}
|
||||
if(decode_chroma){
|
||||
pred_mode= ff_h264_check_intra_pred_mode(h, get_ue_golomb_31(&s->gb), 1);
|
||||
pred_mode= ff_h264_check_intra_chroma_pred_mode(h, get_ue_golomb_31(&s->gb));
|
||||
if(pred_mode < 0)
|
||||
return -1;
|
||||
h->chroma_pred_mode= pred_mode;
|
||||
|
@@ -89,8 +89,7 @@ static void fill_colmap(H264Context *h, int map[2][16+32], int list, int field,
|
||||
for(j=start; j<end; j++){
|
||||
if(4*h->ref_list[0][j].frame_num + (h->ref_list[0][j].reference&3) == poc){
|
||||
int cur_ref= mbafi ? (j-16)^field : j;
|
||||
if(ref1->mbaff)
|
||||
map[list][2*old_ref + (rfield^field) + 16] = cur_ref;
|
||||
map[list][2*old_ref + (rfield^field) + 16] = cur_ref;
|
||||
if(rfield == field || !interl)
|
||||
map[list][old_ref] = cur_ref;
|
||||
break;
|
||||
@@ -253,10 +252,6 @@ static void pred_spatial_direct_motion(H264Context * const h, int *mb_type){
|
||||
mb_type_col[1] = h->ref_list[1][0].mb_type[mb_xy + s->mb_stride];
|
||||
b8_stride = 2+4*s->mb_stride;
|
||||
b4_stride *= 6;
|
||||
if(IS_INTERLACED(mb_type_col[0]) != IS_INTERLACED(mb_type_col[1])){
|
||||
mb_type_col[0] &= ~MB_TYPE_INTERLACED;
|
||||
mb_type_col[1] &= ~MB_TYPE_INTERLACED;
|
||||
}
|
||||
|
||||
sub_mb_type |= MB_TYPE_16x16|MB_TYPE_DIRECT2; /* B_SUB_8x8 */
|
||||
if( (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA)
|
||||
|
@@ -251,12 +251,6 @@ static int h264_parse(AVCodecParserContext *s,
|
||||
h->got_first = 1;
|
||||
if (avctx->extradata_size) {
|
||||
h->s.avctx = avctx;
|
||||
// must be done like in decoder, otherwise opening the parser,
|
||||
// letting it create extradata and then closing and opening again
|
||||
// will cause has_b_frames to be always set.
|
||||
// Note that estimate_timings_from_pts does exactly this.
|
||||
if (!avctx->has_b_frames)
|
||||
h->s.low_delay = 1;
|
||||
ff_h264_decode_extradata(h, avctx->extradata, avctx->extradata_size);
|
||||
}
|
||||
}
|
||||
|
@@ -143,8 +143,8 @@ static inline int decode_hrd_parameters(H264Context *h, SPS *sps){
|
||||
get_bits(&s->gb, 4); /* bit_rate_scale */
|
||||
get_bits(&s->gb, 4); /* cpb_size_scale */
|
||||
for(i=0; i<cpb_count; i++){
|
||||
get_ue_golomb_long(&s->gb); /* bit_rate_value_minus1 */
|
||||
get_ue_golomb_long(&s->gb); /* cpb_size_value_minus1 */
|
||||
get_ue_golomb(&s->gb); /* bit_rate_value_minus1 */
|
||||
get_ue_golomb(&s->gb); /* cpb_size_value_minus1 */
|
||||
get_bits1(&s->gb); /* cbr_flag */
|
||||
}
|
||||
sps->initial_cpb_removal_delay_length = get_bits(&s->gb, 5) + 1;
|
||||
@@ -342,12 +342,8 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){
|
||||
|
||||
if(sps->profile_idc >= 100){ //high profile
|
||||
sps->chroma_format_idc= get_ue_golomb_31(&s->gb);
|
||||
if (sps->chroma_format_idc > 3U) {
|
||||
av_log(h->s.avctx, AV_LOG_ERROR, "chroma_format_idc %d is illegal\n", sps->chroma_format_idc);
|
||||
goto fail;
|
||||
} else if(sps->chroma_format_idc == 3) {
|
||||
if(sps->chroma_format_idc == 3)
|
||||
sps->residual_color_transform_flag = get_bits1(&s->gb);
|
||||
}
|
||||
sps->bit_depth_luma = get_ue_golomb(&s->gb) + 8;
|
||||
sps->bit_depth_chroma = get_ue_golomb(&s->gb) + 8;
|
||||
if (sps->bit_depth_luma > 12U || sps->bit_depth_chroma > 12U) {
|
||||
@@ -485,14 +481,10 @@ int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length){
|
||||
unsigned int pps_id= get_ue_golomb(&s->gb);
|
||||
PPS *pps;
|
||||
const int qp_bd_offset = 6*(h->sps.bit_depth_luma-8);
|
||||
int bits_left;
|
||||
|
||||
if(pps_id >= MAX_PPS_COUNT) {
|
||||
av_log(h->s.avctx, AV_LOG_ERROR, "pps_id (%d) out of range\n", pps_id);
|
||||
return -1;
|
||||
} else if (h->sps.bit_depth_luma > 10) {
|
||||
av_log(h->s.avctx, AV_LOG_ERROR, "Unimplemented luma bit depth=%d (max=10)\n", h->sps.bit_depth_luma);
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
|
||||
pps= av_mallocz(sizeof(PPS));
|
||||
@@ -565,9 +557,7 @@ int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length){
|
||||
memcpy(pps->scaling_matrix4, h->sps_buffers[pps->sps_id]->scaling_matrix4, sizeof(pps->scaling_matrix4));
|
||||
memcpy(pps->scaling_matrix8, h->sps_buffers[pps->sps_id]->scaling_matrix8, sizeof(pps->scaling_matrix8));
|
||||
|
||||
bits_left = bit_length - get_bits_count(&s->gb);
|
||||
if (bits_left && (bits_left > 8 ||
|
||||
show_bits(&s->gb, bits_left) != 1 << (bits_left - 1))) {
|
||||
if(get_bits_count(&s->gb) < bit_length){
|
||||
pps->transform_8x8_mode= get_bits1(&s->gb);
|
||||
decode_scaling_matrices(h, h->sps_buffers[pps->sps_id], pps, 0, pps->scaling_matrix4, pps->scaling_matrix8);
|
||||
pps->chroma_qp_index_offset[1]= get_se_golomb(&s->gb); //second_chroma_qp_index_offset
|
||||
|
@@ -40,7 +40,7 @@
|
||||
#undef BIT_DEPTH
|
||||
|
||||
static void pred4x4_vertical_vp8_c(uint8_t *src, const uint8_t *topright, int stride){
|
||||
const unsigned lt = src[-1-1*stride];
|
||||
const int lt= src[-1-1*stride];
|
||||
LOAD_TOP_EDGE
|
||||
LOAD_TOP_RIGHT_EDGE
|
||||
uint32_t v = PACK_4U8((lt + 2*t0 + t1 + 2) >> 2,
|
||||
@@ -55,7 +55,7 @@ static void pred4x4_vertical_vp8_c(uint8_t *src, const uint8_t *topright, int st
|
||||
}
|
||||
|
||||
static void pred4x4_horizontal_vp8_c(uint8_t *src, const uint8_t *topright, int stride){
|
||||
const unsigned lt = src[-1-1*stride];
|
||||
const int lt= src[-1-1*stride];
|
||||
LOAD_LEFT_EDGE
|
||||
|
||||
AV_WN32A(src+0*stride, ((lt + 2*l0 + l1 + 2) >> 2)*0x01010101);
|
||||
@@ -292,7 +292,7 @@ static void pred16x16_tm_vp8_c(uint8_t *src, int stride){
|
||||
|
||||
static void pred8x8_left_dc_rv40_c(uint8_t *src, int stride){
|
||||
int i;
|
||||
unsigned dc0;
|
||||
int dc0;
|
||||
|
||||
dc0=0;
|
||||
for(i=0;i<8; i++)
|
||||
@@ -307,7 +307,7 @@ static void pred8x8_left_dc_rv40_c(uint8_t *src, int stride){
|
||||
|
||||
static void pred8x8_top_dc_rv40_c(uint8_t *src, int stride){
|
||||
int i;
|
||||
unsigned dc0;
|
||||
int dc0;
|
||||
|
||||
dc0=0;
|
||||
for(i=0;i<8; i++)
|
||||
@@ -322,7 +322,7 @@ static void pred8x8_top_dc_rv40_c(uint8_t *src, int stride){
|
||||
|
||||
static void pred8x8_dc_rv40_c(uint8_t *src, int stride){
|
||||
int i;
|
||||
unsigned dc0 = 0;
|
||||
int dc0=0;
|
||||
|
||||
for(i=0;i<4; i++){
|
||||
dc0+= src[-1+i*stride] + src[i-stride];
|
||||
|
@@ -120,28 +120,28 @@ static void FUNCC(pred4x4_129_dc)(uint8_t *_src, const uint8_t *topright, int _s
|
||||
|
||||
|
||||
#define LOAD_TOP_RIGHT_EDGE\
|
||||
const unsigned av_unused t4 = topright[0];\
|
||||
const unsigned av_unused t5 = topright[1];\
|
||||
const unsigned av_unused t6 = topright[2];\
|
||||
const unsigned av_unused t7 = topright[3];\
|
||||
const int av_unused t4= topright[0];\
|
||||
const int av_unused t5= topright[1];\
|
||||
const int av_unused t6= topright[2];\
|
||||
const int av_unused t7= topright[3];\
|
||||
|
||||
#define LOAD_DOWN_LEFT_EDGE\
|
||||
const unsigned av_unused l4 = src[-1+4*stride];\
|
||||
const unsigned av_unused l5 = src[-1+5*stride];\
|
||||
const unsigned av_unused l6 = src[-1+6*stride];\
|
||||
const unsigned av_unused l7 = src[-1+7*stride];\
|
||||
const int av_unused l4= src[-1+4*stride];\
|
||||
const int av_unused l5= src[-1+5*stride];\
|
||||
const int av_unused l6= src[-1+6*stride];\
|
||||
const int av_unused l7= src[-1+7*stride];\
|
||||
|
||||
#define LOAD_LEFT_EDGE\
|
||||
const unsigned av_unused l0 = src[-1+0*stride];\
|
||||
const unsigned av_unused l1 = src[-1+1*stride];\
|
||||
const unsigned av_unused l2 = src[-1+2*stride];\
|
||||
const unsigned av_unused l3 = src[-1+3*stride];\
|
||||
const int av_unused l0= src[-1+0*stride];\
|
||||
const int av_unused l1= src[-1+1*stride];\
|
||||
const int av_unused l2= src[-1+2*stride];\
|
||||
const int av_unused l3= src[-1+3*stride];\
|
||||
|
||||
#define LOAD_TOP_EDGE\
|
||||
const unsigned av_unused t0 = src[ 0-1*stride];\
|
||||
const unsigned av_unused t1 = src[ 1-1*stride];\
|
||||
const unsigned av_unused t2 = src[ 2-1*stride];\
|
||||
const unsigned av_unused t3 = src[ 3-1*stride];\
|
||||
const int av_unused t0= src[ 0-1*stride];\
|
||||
const int av_unused t1= src[ 1-1*stride];\
|
||||
const int av_unused t2= src[ 2-1*stride];\
|
||||
const int av_unused t3= src[ 3-1*stride];\
|
||||
|
||||
static void FUNCC(pred4x4_down_right)(uint8_t *_src, const uint8_t *topright, int _stride){
|
||||
pixel *src = (pixel*)_src;
|
||||
|
@@ -82,15 +82,13 @@ typedef struct HYuvContext{
|
||||
DSPContext dsp;
|
||||
}HYuvContext;
|
||||
|
||||
#define classic_shift_luma_table_size 42
|
||||
static const unsigned char classic_shift_luma[classic_shift_luma_table_size + FF_INPUT_BUFFER_PADDING_SIZE] = {
|
||||
static const unsigned char classic_shift_luma[] = {
|
||||
34,36,35,69,135,232,9,16,10,24,11,23,12,16,13,10,14,8,15,8,
|
||||
16,8,17,20,16,10,207,206,205,236,11,8,10,21,9,23,8,8,199,70,
|
||||
69,68, 0
|
||||
};
|
||||
|
||||
#define classic_shift_chroma_table_size 59
|
||||
static const unsigned char classic_shift_chroma[classic_shift_chroma_table_size + FF_INPUT_BUFFER_PADDING_SIZE] = {
|
||||
static const unsigned char classic_shift_chroma[] = {
|
||||
66,36,37,38,39,40,41,75,76,77,110,239,144,81,82,83,84,85,118,183,
|
||||
56,57,88,89,56,89,154,57,58,57,26,141,57,56,58,57,58,57,184,119,
|
||||
214,245,116,83,82,49,80,79,78,77,44,75,41,40,39,38,37,36,34, 0
|
||||
@@ -186,7 +184,7 @@ static int read_len_table(uint8_t *dst, GetBitContext *gb){
|
||||
if(repeat==0)
|
||||
repeat= get_bits(gb, 8);
|
||||
//printf("%d %d\n", val, repeat);
|
||||
if(i+repeat > 256 || get_bits_left(gb) < 0) {
|
||||
if(i+repeat > 256) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error reading huffman table\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -368,10 +366,10 @@ static int read_old_huffman_tables(HYuvContext *s){
|
||||
GetBitContext gb;
|
||||
int i;
|
||||
|
||||
init_get_bits(&gb, classic_shift_luma, classic_shift_luma_table_size*8);
|
||||
init_get_bits(&gb, classic_shift_luma, sizeof(classic_shift_luma)*8);
|
||||
if(read_len_table(s->len[0], &gb)<0)
|
||||
return -1;
|
||||
init_get_bits(&gb, classic_shift_chroma, classic_shift_chroma_table_size*8);
|
||||
init_get_bits(&gb, classic_shift_chroma, sizeof(classic_shift_chroma)*8);
|
||||
if(read_len_table(s->len[1], &gb)<0)
|
||||
return -1;
|
||||
|
||||
@@ -517,7 +515,7 @@ s->bgr32=1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return AVERROR_INVALIDDATA;
|
||||
assert(0);
|
||||
}
|
||||
|
||||
alloc_temp(s);
|
||||
|
@@ -72,7 +72,6 @@ typedef struct IdcinContext {
|
||||
hnode huff_nodes[256][HUF_TOKENS*2];
|
||||
int num_huff_nodes[256];
|
||||
|
||||
uint32_t pal[256];
|
||||
} IdcinContext;
|
||||
|
||||
/*
|
||||
@@ -215,7 +214,7 @@ static int idcin_decode_frame(AVCodecContext *avctx,
|
||||
const uint8_t *buf = avpkt->data;
|
||||
int buf_size = avpkt->size;
|
||||
IdcinContext *s = avctx->priv_data;
|
||||
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
|
||||
AVPaletteControl *palette_control = avctx->palctrl;
|
||||
|
||||
s->buf = buf;
|
||||
s->size = buf_size;
|
||||
@@ -230,12 +229,13 @@ static int idcin_decode_frame(AVCodecContext *avctx,
|
||||
|
||||
idcin_decode_vlcs(s);
|
||||
|
||||
if (pal) {
|
||||
s->frame.palette_has_changed = 1;
|
||||
memcpy(s->pal, pal, AVPALETTE_SIZE);
|
||||
}
|
||||
/* make the palette available on the way out */
|
||||
memcpy(s->frame.data[1], s->pal, AVPALETTE_SIZE);
|
||||
memcpy(s->frame.data[1], palette_control->palette, PALETTE_COUNT * 4);
|
||||
/* If palette changed inform application*/
|
||||
if (palette_control->palette_changed) {
|
||||
palette_control->palette_changed = 0;
|
||||
s->frame.palette_has_changed = 1;
|
||||
}
|
||||
|
||||
*data_size = sizeof(AVFrame);
|
||||
*(AVFrame*)data = s->frame;
|
||||
|
@@ -176,13 +176,7 @@ static int extract_header(AVCodecContext *const avctx,
|
||||
const uint8_t *buf;
|
||||
unsigned buf_size;
|
||||
IffContext *s = avctx->priv_data;
|
||||
int palette_size;
|
||||
|
||||
if (avctx->extradata_size < 2) {
|
||||
av_log(avctx, AV_LOG_ERROR, "not enough extradata\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
palette_size = avctx->extradata_size - AV_RB16(avctx->extradata);
|
||||
int palette_size = avctx->extradata_size - AV_RB16(avctx->extradata);
|
||||
|
||||
if (avpkt) {
|
||||
int image_size;
|
||||
@@ -198,6 +192,8 @@ static int extract_header(AVCodecContext *const avctx,
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
} else {
|
||||
if (avctx->extradata_size < 2)
|
||||
return AVERROR_INVALIDDATA;
|
||||
buf = avctx->extradata;
|
||||
buf_size = bytestream_get_be16(&buf);
|
||||
if (buf_size <= 1 || palette_size < 0) {
|
||||
@@ -285,12 +281,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
int err;
|
||||
|
||||
if (avctx->bits_per_coded_sample <= 8) {
|
||||
int palette_size;
|
||||
|
||||
if (avctx->extradata_size >= 2)
|
||||
palette_size = avctx->extradata_size - AV_RB16(avctx->extradata);
|
||||
else
|
||||
palette_size = 0;
|
||||
int palette_size = avctx->extradata_size - AV_RB16(avctx->extradata);
|
||||
avctx->pix_fmt = (avctx->bits_per_coded_sample < 8) ||
|
||||
(avctx->extradata_size >= 2 && palette_size) ? PIX_FMT_PAL8 : PIX_FMT_GRAY8;
|
||||
} else if (avctx->bits_per_coded_sample <= 32) {
|
||||
|
@@ -104,15 +104,10 @@ static VLC_TYPE vlc_tables[VLC_TABLES_SIZE][2];
|
||||
|
||||
static av_cold int imc_decode_init(AVCodecContext * avctx)
|
||||
{
|
||||
int i, j, ret;
|
||||
int i, j;
|
||||
IMCContext *q = avctx->priv_data;
|
||||
double r1, r2;
|
||||
|
||||
if (avctx->channels != 1) {
|
||||
av_log_ask_for_sample(avctx, "Number of channels is not supported\n");
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
|
||||
q->decoder_reset = 1;
|
||||
|
||||
for(i = 0; i < BANDS; i++)
|
||||
@@ -161,10 +156,7 @@ static av_cold int imc_decode_init(AVCodecContext * avctx)
|
||||
}
|
||||
q->one_div_log2 = 1/log(2);
|
||||
|
||||
if ((ret = ff_fft_init(&q->fft, 7, 1))) {
|
||||
av_log(avctx, AV_LOG_INFO, "FFT init failed\n");
|
||||
return ret;
|
||||
}
|
||||
ff_fft_init(&q->fft, 7, 1);
|
||||
dsputil_init(&q->dsp, avctx);
|
||||
avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
|
||||
avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
|
||||
|
@@ -424,11 +424,40 @@ const char *avcodec_get_pix_fmt_name(enum PixelFormat pix_fmt)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 53
|
||||
enum PixelFormat avcodec_get_pix_fmt(const char *name)
|
||||
{
|
||||
return av_get_pix_fmt(name);
|
||||
}
|
||||
|
||||
void avcodec_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt)
|
||||
{
|
||||
av_get_pix_fmt_string(buf, buf_size, pix_fmt);
|
||||
}
|
||||
#endif
|
||||
|
||||
int ff_is_hwaccel_pix_fmt(enum PixelFormat pix_fmt)
|
||||
{
|
||||
return av_pix_fmt_descriptors[pix_fmt].flags & PIX_FMT_HWACCEL;
|
||||
}
|
||||
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 53
|
||||
int ff_set_systematic_pal(uint32_t pal[256], enum PixelFormat pix_fmt){
|
||||
return ff_set_systematic_pal2(pal, pix_fmt);
|
||||
}
|
||||
|
||||
int ff_fill_linesize(AVPicture *picture, enum PixelFormat pix_fmt, int width)
|
||||
{
|
||||
return av_image_fill_linesizes(picture->linesize, pix_fmt, width);
|
||||
}
|
||||
|
||||
int ff_fill_pointer(AVPicture *picture, uint8_t *ptr, enum PixelFormat pix_fmt,
|
||||
int height)
|
||||
{
|
||||
return av_image_fill_pointers(picture->data, pix_fmt, height, ptr, picture->linesize);
|
||||
}
|
||||
#endif
|
||||
|
||||
int avpicture_fill(AVPicture *picture, uint8_t *ptr,
|
||||
enum PixelFormat pix_fmt, int width, int height)
|
||||
{
|
||||
@@ -470,16 +499,6 @@ int avpicture_layout(const AVPicture* src, enum PixelFormat pix_fmt, int width,
|
||||
}
|
||||
}
|
||||
|
||||
switch (pix_fmt) {
|
||||
case PIX_FMT_RGB8:
|
||||
case PIX_FMT_BGR8:
|
||||
case PIX_FMT_RGB4_BYTE:
|
||||
case PIX_FMT_BGR4_BYTE:
|
||||
case PIX_FMT_GRAY8:
|
||||
// do not include palette for these pseudo-paletted formats
|
||||
return size;
|
||||
}
|
||||
|
||||
if (desc->flags & PIX_FMT_PAL)
|
||||
memcpy((unsigned char *)(((size_t)dest + 3) & ~3), src->data[1], 256 * 4);
|
||||
|
||||
@@ -673,6 +692,28 @@ enum PixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum PixelForma
|
||||
return dst_pix_fmt;
|
||||
}
|
||||
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 53
|
||||
void ff_img_copy_plane(uint8_t *dst, int dst_wrap,
|
||||
const uint8_t *src, int src_wrap,
|
||||
int width, int height)
|
||||
{
|
||||
av_image_copy_plane(dst, dst_wrap, src, src_wrap, width, height);
|
||||
}
|
||||
|
||||
int ff_get_plane_bytewidth(enum PixelFormat pix_fmt, int width, int plane)
|
||||
{
|
||||
return av_image_get_linesize(pix_fmt, width, plane);
|
||||
}
|
||||
|
||||
void av_picture_data_copy(uint8_t *dst_data[4], int dst_linesize[4],
|
||||
uint8_t *src_data[4], int src_linesize[4],
|
||||
enum PixelFormat pix_fmt, int width, int height)
|
||||
{
|
||||
av_image_copy(dst_data, dst_linesize, src_data, src_linesize,
|
||||
pix_fmt, width, height);
|
||||
}
|
||||
#endif
|
||||
|
||||
void av_picture_copy(AVPicture *dst, const AVPicture *src,
|
||||
enum PixelFormat pix_fmt, int width, int height)
|
||||
{
|
||||
|
@@ -219,10 +219,6 @@ static int decode_gop_header(IVI5DecContext *ctx, AVCodecContext *avctx)
|
||||
}
|
||||
|
||||
if (band->blk_size == 8) {
|
||||
if(quant_mat >= 5){
|
||||
av_log(avctx, AV_LOG_ERROR, "quant_mat %d too large!\n", quant_mat);
|
||||
return -1;
|
||||
}
|
||||
band->intra_base = &ivi5_base_quant_8x8_intra[quant_mat][0];
|
||||
band->inter_base = &ivi5_base_quant_8x8_inter[quant_mat][0];
|
||||
band->intra_scale = &ivi5_scale_quant_8x8_intra[quant_mat][0];
|
||||
|
@@ -77,7 +77,7 @@ int ff_intel_h263_decode_picture_header(MpegEncContext *s)
|
||||
}
|
||||
if(get_bits(&s->gb, 2))
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
|
||||
s->loop_filter = get_bits1(&s->gb) * !s->avctx->lowres;
|
||||
s->loop_filter = get_bits1(&s->gb);
|
||||
if(get_bits1(&s->gb))
|
||||
av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
|
||||
if(get_bits1(&s->gb))
|
||||
|
@@ -69,7 +69,6 @@ typedef struct IpvideoContext {
|
||||
int stride;
|
||||
int upper_motion_limit_offset;
|
||||
|
||||
uint32_t pal[256];
|
||||
} IpvideoContext;
|
||||
|
||||
#define CHECK_STREAM_PTR(stream_ptr, stream_end, n) \
|
||||
@@ -962,7 +961,7 @@ static void ipvideo_decode_opcodes(IpvideoContext *s)
|
||||
|
||||
if (!s->is_16bpp) {
|
||||
/* this is PAL8, so make the palette available */
|
||||
memcpy(s->current_frame.data[1], s->pal, AVPALETTE_SIZE);
|
||||
memcpy(s->current_frame.data[1], s->avctx->palctrl->palette, PALETTE_COUNT * 4);
|
||||
|
||||
s->stride = s->current_frame.linesize[0];
|
||||
s->stream_ptr = s->buf + 14; /* data starts 14 bytes in */
|
||||
@@ -1016,6 +1015,10 @@ static av_cold int ipvideo_decode_init(AVCodecContext *avctx)
|
||||
|
||||
s->is_16bpp = avctx->bits_per_coded_sample == 16;
|
||||
avctx->pix_fmt = s->is_16bpp ? PIX_FMT_RGB555 : PIX_FMT_PAL8;
|
||||
if (!s->is_16bpp && s->avctx->palctrl == NULL) {
|
||||
av_log(avctx, AV_LOG_ERROR, " Interplay video: palette expected.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
dsputil_init(&s->dsp, avctx);
|
||||
|
||||
@@ -1038,6 +1041,7 @@ static int ipvideo_decode_frame(AVCodecContext *avctx,
|
||||
const uint8_t *buf = avpkt->data;
|
||||
int buf_size = avpkt->size;
|
||||
IpvideoContext *s = avctx->priv_data;
|
||||
AVPaletteControl *palette_control = avctx->palctrl;
|
||||
|
||||
/* compressed buffer needs to be large enough to at least hold an entire
|
||||
* decoding map */
|
||||
@@ -1054,16 +1058,13 @@ static int ipvideo_decode_frame(AVCodecContext *avctx,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!s->is_16bpp) {
|
||||
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
|
||||
if (pal) {
|
||||
s->current_frame.palette_has_changed = 1;
|
||||
memcpy(s->pal, pal, AVPALETTE_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
ipvideo_decode_opcodes(s);
|
||||
|
||||
if (!s->is_16bpp && palette_control->palette_changed) {
|
||||
palette_control->palette_changed = 0;
|
||||
s->current_frame.palette_has_changed = 1;
|
||||
}
|
||||
|
||||
*data_size = sizeof(AVFrame);
|
||||
*(AVFrame*)data = s->current_frame;
|
||||
|
||||
|
@@ -961,8 +961,6 @@ int h263_decode_picture_header(MpegEncContext *s)
|
||||
s->h263_aic = get_bits1(&s->gb); /* Advanced Intra Coding (AIC) */
|
||||
s->loop_filter= get_bits1(&s->gb);
|
||||
s->unrestricted_mv = s->umvplus || s->obmc || s->loop_filter;
|
||||
if(s->avctx->lowres)
|
||||
s->loop_filter = 0;
|
||||
|
||||
s->h263_slice_structured= get_bits1(&s->gb);
|
||||
if (get_bits1(&s->gb) != 0) {
|
||||
|
@@ -321,7 +321,7 @@ int ff_j2k_dwt_init(DWTContext *s, uint16_t border[2][2], int decomp_levels, int
|
||||
int i, j, lev = decomp_levels, maxlen,
|
||||
b[2][2];
|
||||
|
||||
if ((unsigned)decomp_levels >= FF_DWT_MAX_DECLVLS)
|
||||
if (decomp_levels >= FF_DWT_MAX_DECLVLS)
|
||||
return AVERROR_INVALIDDATA;
|
||||
s->ndeclevels = decomp_levels;
|
||||
s->type = type;
|
||||
|
@@ -359,7 +359,7 @@ static int get_qcx(J2kDecoderContext *s, int n, J2kQuantStyle *q)
|
||||
|
||||
if (q->quantsty == J2K_QSTY_NONE){
|
||||
n -= 3;
|
||||
if (s->buf_end - s->buf < n || 32*3 < n)
|
||||
if (s->buf_end - s->buf < n)
|
||||
return AVERROR(EINVAL);
|
||||
for (i = 0; i < n; i++)
|
||||
q->expn[i] = bytestream_get_byte(&s->buf) >> 3;
|
||||
@@ -376,7 +376,7 @@ static int get_qcx(J2kDecoderContext *s, int n, J2kQuantStyle *q)
|
||||
}
|
||||
} else{
|
||||
n = (n - 3) >> 1;
|
||||
if (s->buf_end - s->buf < n || 32*3 < n)
|
||||
if (s->buf_end - s->buf < n)
|
||||
return AVERROR(EINVAL);
|
||||
for (i = 0; i < n; i++){
|
||||
x = bytestream_get_be16(&s->buf);
|
||||
@@ -421,10 +421,6 @@ static uint8_t get_sot(J2kDecoderContext *s)
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
s->curtileno = bytestream_get_be16(&s->buf); ///< Isot
|
||||
if((unsigned)s->curtileno >= s->numXtiles * s->numYtiles){
|
||||
s->curtileno=0;
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
s->buf += 4; ///< Psot (ignored)
|
||||
|
||||
|
@@ -143,10 +143,6 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
buf += 5;
|
||||
|
||||
if (video_size) {
|
||||
if(video_size < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "video size %d invalid\n", video_size);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
if (avctx->reget_buffer(avctx, &s->frame) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
return -1;
|
||||
@@ -154,7 +150,7 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
|
||||
if (video_type == 0 || video_type == 1) {
|
||||
GetBitContext gb;
|
||||
init_get_bits(&gb, buf, 8 * FFMIN(video_size, buf_end - buf));
|
||||
init_get_bits(&gb, buf, FFMIN(video_size, (buf_end - buf) * 8));
|
||||
|
||||
for (j = 0; j < avctx->height; j += 8)
|
||||
for (i = 0; i < avctx->width; i += 8)
|
||||
|
@@ -30,26 +30,19 @@
|
||||
|
||||
typedef struct {
|
||||
AVCodecContext *avctx;
|
||||
AVFrame prev, cur;
|
||||
AVFrame pic;
|
||||
uint16_t *prev, *cur;
|
||||
} KgvContext;
|
||||
|
||||
static void decode_flush(AVCodecContext *avctx)
|
||||
{
|
||||
KgvContext * const c = avctx->priv_data;
|
||||
|
||||
if (c->prev.data[0])
|
||||
avctx->release_buffer(avctx, &c->prev);
|
||||
}
|
||||
|
||||
static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
|
||||
{
|
||||
const uint8_t *buf = avpkt->data;
|
||||
const uint8_t *buf_end = buf + avpkt->size;
|
||||
KgvContext * const c = avctx->priv_data;
|
||||
int offsets[8];
|
||||
int offsets[7];
|
||||
uint16_t *out, *prev;
|
||||
int outcnt = 0, maxcnt;
|
||||
int w, h, i, res;
|
||||
int w, h, i;
|
||||
|
||||
if (avpkt->size < 2)
|
||||
return -1;
|
||||
@@ -61,25 +54,22 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
|
||||
if (av_image_check_size(w, h, 0, avctx))
|
||||
return -1;
|
||||
|
||||
if (w != avctx->width || h != avctx->height) {
|
||||
if (c->prev.data[0])
|
||||
avctx->release_buffer(avctx, &c->prev);
|
||||
if (w != avctx->width || h != avctx->height)
|
||||
avcodec_set_dimensions(avctx, w, h);
|
||||
}
|
||||
|
||||
maxcnt = w * h;
|
||||
|
||||
c->cur.reference = 3;
|
||||
if ((res = avctx->get_buffer(avctx, &c->cur)) < 0)
|
||||
return res;
|
||||
out = (uint16_t *) c->cur.data[0];
|
||||
if (c->prev.data[0]) {
|
||||
prev = (uint16_t *) c->prev.data[0];
|
||||
} else {
|
||||
prev = NULL;
|
||||
}
|
||||
out = av_realloc(c->cur, w * h * 2);
|
||||
if (!out)
|
||||
return -1;
|
||||
c->cur = out;
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
prev = av_realloc(c->prev, w * h * 2);
|
||||
if (!prev)
|
||||
return -1;
|
||||
c->prev = prev;
|
||||
|
||||
for (i = 0; i < 7; i++)
|
||||
offsets[i] = -1;
|
||||
|
||||
while (outcnt < maxcnt && buf_end - 2 > buf) {
|
||||
@@ -90,7 +80,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
|
||||
out[outcnt++] = code; // rgb555 pixel coded directly
|
||||
} else {
|
||||
int count;
|
||||
int inp_off;
|
||||
uint16_t *inp;
|
||||
|
||||
if ((code & 0x6000) == 0x6000) {
|
||||
@@ -112,14 +101,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
|
||||
if (maxcnt - start < count)
|
||||
break;
|
||||
|
||||
if (!prev) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"Frame reference does not exist\n");
|
||||
break;
|
||||
}
|
||||
|
||||
inp = prev;
|
||||
inp_off = start;
|
||||
inp = prev + start;
|
||||
} else {
|
||||
// copy from earlier in this frame
|
||||
int offset = (code & 0x1FFF) + 1;
|
||||
@@ -137,28 +119,27 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
|
||||
if (outcnt < offset)
|
||||
break;
|
||||
|
||||
inp = out;
|
||||
inp_off = outcnt - offset;
|
||||
inp = out + outcnt - offset;
|
||||
}
|
||||
|
||||
if (maxcnt - outcnt < count)
|
||||
break;
|
||||
|
||||
for (i = inp_off; i < count + inp_off; i++) {
|
||||
for (i = 0; i < count; i++)
|
||||
out[outcnt++] = inp[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (outcnt - maxcnt)
|
||||
av_log(avctx, AV_LOG_DEBUG, "frame finished with %d diff\n", outcnt - maxcnt);
|
||||
|
||||
*data_size = sizeof(AVFrame);
|
||||
*(AVFrame*)data = c->cur;
|
||||
c->pic.data[0] = (uint8_t *)c->cur;
|
||||
c->pic.linesize[0] = w * 2;
|
||||
|
||||
if (c->prev.data[0])
|
||||
avctx->release_buffer(avctx, &c->prev);
|
||||
FFSWAP(AVFrame, c->cur, c->prev);
|
||||
*data_size = sizeof(AVFrame);
|
||||
*(AVFrame*)data = c->pic;
|
||||
|
||||
FFSWAP(uint16_t *, c->cur, c->prev);
|
||||
|
||||
return avpkt->size;
|
||||
}
|
||||
@@ -169,25 +150,29 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
|
||||
c->avctx = avctx;
|
||||
avctx->pix_fmt = PIX_FMT_RGB555;
|
||||
avctx->flags |= CODEC_FLAG_EMU_EDGE;
|
||||
avcodec_get_frame_defaults(&c->pic);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static av_cold int decode_end(AVCodecContext *avctx)
|
||||
{
|
||||
decode_flush(avctx);
|
||||
KgvContext * const c = avctx->priv_data;
|
||||
|
||||
av_freep(&c->cur);
|
||||
av_freep(&c->prev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
AVCodec ff_kgv1_decoder = {
|
||||
.name = "kgv1",
|
||||
.type = AVMEDIA_TYPE_VIDEO,
|
||||
.id = CODEC_ID_KGV1,
|
||||
.priv_data_size = sizeof(KgvContext),
|
||||
.init = decode_init,
|
||||
.close = decode_end,
|
||||
.decode = decode_frame,
|
||||
.flush = decode_flush,
|
||||
"kgv1",
|
||||
AVMEDIA_TYPE_VIDEO,
|
||||
CODEC_ID_KGV1,
|
||||
sizeof(KgvContext),
|
||||
decode_init,
|
||||
NULL,
|
||||
decode_end,
|
||||
decode_frame,
|
||||
.long_name = NULL_IF_CONFIG_SMALL("Kega Game Video"),
|
||||
};
|
||||
|
@@ -33,7 +33,6 @@
|
||||
#define KMVC_KEYFRAME 0x80
|
||||
#define KMVC_PALETTE 0x40
|
||||
#define KMVC_METHOD 0x0F
|
||||
#define MAX_PALSIZE 256
|
||||
|
||||
/*
|
||||
* Decoder context
|
||||
@@ -44,7 +43,7 @@ typedef struct KmvcContext {
|
||||
|
||||
int setpal;
|
||||
int palsize;
|
||||
uint32_t pal[MAX_PALSIZE];
|
||||
uint32_t pal[256];
|
||||
uint8_t *cur, *prev;
|
||||
uint8_t *frm0, *frm1;
|
||||
} KmvcContext;
|
||||
@@ -58,21 +57,17 @@ typedef struct BitBuf {
|
||||
|
||||
#define kmvc_init_getbits(bb, src) bb.bits = 7; bb.bitbuf = *src++;
|
||||
|
||||
#define kmvc_getbit(bb, src, src_end, res) {\
|
||||
#define kmvc_getbit(bb, src, res) {\
|
||||
res = 0; \
|
||||
if (bb.bitbuf & (1 << bb.bits)) res = 1; \
|
||||
bb.bits--; \
|
||||
if(bb.bits == -1) { \
|
||||
if (src >= src_end) { \
|
||||
av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n"); \
|
||||
return AVERROR_INVALIDDATA; \
|
||||
} \
|
||||
bb.bitbuf = *src++; \
|
||||
bb.bits = 7; \
|
||||
} \
|
||||
}
|
||||
|
||||
static int kmvc_decode_intra_8x8(KmvcContext * ctx, const uint8_t * src, int src_size, int w, int h)
|
||||
static void kmvc_decode_intra_8x8(KmvcContext * ctx, const uint8_t * src, int w, int h)
|
||||
{
|
||||
BitBuf bb;
|
||||
int res, val;
|
||||
@@ -80,18 +75,13 @@ static int kmvc_decode_intra_8x8(KmvcContext * ctx, const uint8_t * src, int src
|
||||
int bx, by;
|
||||
int l0x, l1x, l0y, l1y;
|
||||
int mx, my;
|
||||
const uint8_t *src_end = src + src_size;
|
||||
|
||||
kmvc_init_getbits(bb, src);
|
||||
|
||||
for (by = 0; by < h; by += 8)
|
||||
for (bx = 0; bx < w; bx += 8) {
|
||||
kmvc_getbit(bb, src, src_end, res);
|
||||
kmvc_getbit(bb, src, res);
|
||||
if (!res) { // fill whole 8x8 block
|
||||
if (src >= src_end) {
|
||||
av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
val = *src++;
|
||||
for (i = 0; i < 64; i++)
|
||||
BLK(ctx->cur, bx + (i & 0x7), by + (i >> 3)) = val;
|
||||
@@ -99,22 +89,14 @@ static int kmvc_decode_intra_8x8(KmvcContext * ctx, const uint8_t * src, int src
|
||||
for (i = 0; i < 4; i++) {
|
||||
l0x = bx + (i & 1) * 4;
|
||||
l0y = by + (i & 2) * 2;
|
||||
kmvc_getbit(bb, src, src_end, res);
|
||||
kmvc_getbit(bb, src, res);
|
||||
if (!res) {
|
||||
kmvc_getbit(bb, src, src_end, res);
|
||||
kmvc_getbit(bb, src, res);
|
||||
if (!res) { // fill whole 4x4 block
|
||||
if (src >= src_end) {
|
||||
av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
val = *src++;
|
||||
for (j = 0; j < 16; j++)
|
||||
BLK(ctx->cur, l0x + (j & 3), l0y + (j >> 2)) = val;
|
||||
} else { // copy block from already decoded place
|
||||
if (src >= src_end) {
|
||||
av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
val = *src++;
|
||||
mx = val & 0xF;
|
||||
my = val >> 4;
|
||||
@@ -126,24 +108,16 @@ static int kmvc_decode_intra_8x8(KmvcContext * ctx, const uint8_t * src, int src
|
||||
for (j = 0; j < 4; j++) {
|
||||
l1x = l0x + (j & 1) * 2;
|
||||
l1y = l0y + (j & 2);
|
||||
kmvc_getbit(bb, src, src_end, res);
|
||||
kmvc_getbit(bb, src, res);
|
||||
if (!res) {
|
||||
kmvc_getbit(bb, src, src_end, res);
|
||||
kmvc_getbit(bb, src, res);
|
||||
if (!res) { // fill whole 2x2 block
|
||||
if (src >= src_end) {
|
||||
av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
val = *src++;
|
||||
BLK(ctx->cur, l1x, l1y) = val;
|
||||
BLK(ctx->cur, l1x + 1, l1y) = val;
|
||||
BLK(ctx->cur, l1x, l1y + 1) = val;
|
||||
BLK(ctx->cur, l1x + 1, l1y + 1) = val;
|
||||
} else { // copy block from already decoded place
|
||||
if (src >= src_end) {
|
||||
av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
val = *src++;
|
||||
mx = val & 0xF;
|
||||
my = val >> 4;
|
||||
@@ -166,11 +140,9 @@ static int kmvc_decode_intra_8x8(KmvcContext * ctx, const uint8_t * src, int src
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int kmvc_decode_inter_8x8(KmvcContext * ctx, const uint8_t * src, int src_size, int w, int h)
|
||||
static void kmvc_decode_inter_8x8(KmvcContext * ctx, const uint8_t * src, int w, int h)
|
||||
{
|
||||
BitBuf bb;
|
||||
int res, val;
|
||||
@@ -178,20 +150,15 @@ static int kmvc_decode_inter_8x8(KmvcContext * ctx, const uint8_t * src, int src
|
||||
int bx, by;
|
||||
int l0x, l1x, l0y, l1y;
|
||||
int mx, my;
|
||||
const uint8_t *src_end = src + src_size;
|
||||
|
||||
kmvc_init_getbits(bb, src);
|
||||
|
||||
for (by = 0; by < h; by += 8)
|
||||
for (bx = 0; bx < w; bx += 8) {
|
||||
kmvc_getbit(bb, src, src_end, res);
|
||||
kmvc_getbit(bb, src, res);
|
||||
if (!res) {
|
||||
kmvc_getbit(bb, src, src_end, res);
|
||||
kmvc_getbit(bb, src, res);
|
||||
if (!res) { // fill whole 8x8 block
|
||||
if (src >= src_end) {
|
||||
av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
val = *src++;
|
||||
for (i = 0; i < 64; i++)
|
||||
BLK(ctx->cur, bx + (i & 0x7), by + (i >> 3)) = val;
|
||||
@@ -204,22 +171,14 @@ static int kmvc_decode_inter_8x8(KmvcContext * ctx, const uint8_t * src, int src
|
||||
for (i = 0; i < 4; i++) {
|
||||
l0x = bx + (i & 1) * 4;
|
||||
l0y = by + (i & 2) * 2;
|
||||
kmvc_getbit(bb, src, src_end, res);
|
||||
kmvc_getbit(bb, src, res);
|
||||
if (!res) {
|
||||
kmvc_getbit(bb, src, src_end, res);
|
||||
kmvc_getbit(bb, src, res);
|
||||
if (!res) { // fill whole 4x4 block
|
||||
if (src >= src_end) {
|
||||
av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
val = *src++;
|
||||
for (j = 0; j < 16; j++)
|
||||
BLK(ctx->cur, l0x + (j & 3), l0y + (j >> 2)) = val;
|
||||
} else { // copy block
|
||||
if (src >= src_end) {
|
||||
av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
val = *src++;
|
||||
mx = (val & 0xF) - 8;
|
||||
my = (val >> 4) - 8;
|
||||
@@ -231,24 +190,16 @@ static int kmvc_decode_inter_8x8(KmvcContext * ctx, const uint8_t * src, int src
|
||||
for (j = 0; j < 4; j++) {
|
||||
l1x = l0x + (j & 1) * 2;
|
||||
l1y = l0y + (j & 2);
|
||||
kmvc_getbit(bb, src, src_end, res);
|
||||
kmvc_getbit(bb, src, res);
|
||||
if (!res) {
|
||||
kmvc_getbit(bb, src, src_end, res);
|
||||
kmvc_getbit(bb, src, res);
|
||||
if (!res) { // fill whole 2x2 block
|
||||
if (src >= src_end) {
|
||||
av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
val = *src++;
|
||||
BLK(ctx->cur, l1x, l1y) = val;
|
||||
BLK(ctx->cur, l1x + 1, l1y) = val;
|
||||
BLK(ctx->cur, l1x, l1y + 1) = val;
|
||||
BLK(ctx->cur, l1x + 1, l1y + 1) = val;
|
||||
} else { // copy block
|
||||
if (src >= src_end) {
|
||||
av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
val = *src++;
|
||||
mx = (val & 0xF) - 8;
|
||||
my = (val >> 4) - 8;
|
||||
@@ -271,8 +222,6 @@ static int kmvc_decode_inter_8x8(KmvcContext * ctx, const uint8_t * src, int src
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, AVPacket *avpkt)
|
||||
@@ -284,7 +233,6 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, AVPa
|
||||
int i;
|
||||
int header;
|
||||
int blocksize;
|
||||
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
|
||||
|
||||
if (ctx->pic.data[0])
|
||||
avctx->release_buffer(avctx, &ctx->pic);
|
||||
@@ -316,6 +264,13 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, AVPa
|
||||
ctx->pic.pict_type = AV_PICTURE_TYPE_P;
|
||||
}
|
||||
|
||||
/* if palette has been changed, copy it from palctrl */
|
||||
if (ctx->avctx->palctrl && ctx->avctx->palctrl->palette_changed) {
|
||||
memcpy(ctx->pal, ctx->avctx->palctrl->palette, AVPALETTE_SIZE);
|
||||
ctx->setpal = 1;
|
||||
ctx->avctx->palctrl->palette_changed = 0;
|
||||
}
|
||||
|
||||
if (header & KMVC_PALETTE) {
|
||||
ctx->pic.palette_has_changed = 1;
|
||||
// palette starts from index 1 and has 127 entries
|
||||
@@ -324,11 +279,6 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, AVPa
|
||||
}
|
||||
}
|
||||
|
||||
if (pal) {
|
||||
ctx->pic.palette_has_changed = 1;
|
||||
memcpy(ctx->pal, pal, AVPALETTE_SIZE);
|
||||
}
|
||||
|
||||
if (ctx->setpal) {
|
||||
ctx->setpal = 0;
|
||||
ctx->pic.palette_has_changed = 1;
|
||||
@@ -350,10 +300,10 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, AVPa
|
||||
memcpy(ctx->cur, ctx->prev, 320 * 200);
|
||||
break;
|
||||
case 3:
|
||||
kmvc_decode_intra_8x8(ctx, buf, buf_size, avctx->width, avctx->height);
|
||||
kmvc_decode_intra_8x8(ctx, buf, avctx->width, avctx->height);
|
||||
break;
|
||||
case 4:
|
||||
kmvc_decode_inter_8x8(ctx, buf, buf_size, avctx->width, avctx->height);
|
||||
kmvc_decode_inter_8x8(ctx, buf, avctx->width, avctx->height);
|
||||
break;
|
||||
default:
|
||||
av_log(avctx, AV_LOG_ERROR, "Unknown compression method %i\n", header & KMVC_METHOD);
|
||||
@@ -415,10 +365,6 @@ static av_cold int decode_init(AVCodecContext * avctx)
|
||||
c->palsize = 127;
|
||||
} else {
|
||||
c->palsize = AV_RL16(avctx->extradata + 10);
|
||||
if (c->palsize >= MAX_PALSIZE) {
|
||||
av_log(avctx, AV_LOG_ERROR, "KMVC palette too large\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
}
|
||||
|
||||
if (avctx->extradata_size == 1036) { // palette in extradata
|
||||
@@ -428,6 +374,9 @@ static av_cold int decode_init(AVCodecContext * avctx)
|
||||
src += 4;
|
||||
}
|
||||
c->setpal = 1;
|
||||
if (c->avctx->palctrl) {
|
||||
c->avctx->palctrl->palette_changed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
avcodec_get_frame_defaults(&c->pic);
|
||||
|
@@ -223,29 +223,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
|
||||
len = mszh_dlen;
|
||||
}
|
||||
break;
|
||||
case COMP_MSZH_NOCOMP: {
|
||||
int bppx2;
|
||||
switch (c->imgtype) {
|
||||
case IMGTYPE_YUV111:
|
||||
case IMGTYPE_RGB24:
|
||||
bppx2 = 6;
|
||||
break;
|
||||
case IMGTYPE_YUV422:
|
||||
case IMGTYPE_YUV211:
|
||||
bppx2 = 4;
|
||||
break;
|
||||
case IMGTYPE_YUV411:
|
||||
case IMGTYPE_YUV420:
|
||||
bppx2 = 3;
|
||||
break;
|
||||
default:
|
||||
bppx2 = 0; // will error out below
|
||||
break;
|
||||
}
|
||||
if (len < ((width * height * bppx2) >> 1))
|
||||
return AVERROR_INVALIDDATA;
|
||||
case COMP_MSZH_NOCOMP:
|
||||
break;
|
||||
}
|
||||
default:
|
||||
av_log(avctx, AV_LOG_ERROR, "BUG! Unknown MSZH compression in frame decoder.\n");
|
||||
return -1;
|
||||
@@ -477,7 +456,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
avcodec_get_frame_defaults(&c->pic);
|
||||
if (avctx->extradata_size < 8) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Extradata size too small.\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Check codec type */
|
||||
@@ -526,7 +505,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
break;
|
||||
default:
|
||||
av_log(avctx, AV_LOG_ERROR, "Unsupported image format %d.\n", c->imgtype);
|
||||
return AVERROR_INVALIDDATA;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Detect compression method */
|
||||
@@ -543,7 +522,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
break;
|
||||
default:
|
||||
av_log(avctx, AV_LOG_ERROR, "Unsupported compression format for MSZH (%d).\n", c->compression);
|
||||
return AVERROR_INVALIDDATA;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
#if CONFIG_ZLIB_DECODER
|
||||
@@ -561,7 +540,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
default:
|
||||
if (c->compression < Z_NO_COMPRESSION || c->compression > Z_BEST_COMPRESSION) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Unsupported compression level for ZLIB: (%d).\n", c->compression);
|
||||
return AVERROR_INVALIDDATA;
|
||||
return 1;
|
||||
}
|
||||
av_log(avctx, AV_LOG_DEBUG, "Compression level for ZLIB: (%d).\n", c->compression);
|
||||
}
|
||||
@@ -569,14 +548,14 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
#endif
|
||||
default:
|
||||
av_log(avctx, AV_LOG_ERROR, "BUG! Unknown codec in compression switch.\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Allocate decompression buffer */
|
||||
if (c->decomp_size) {
|
||||
if ((c->decomp_buf = av_malloc(max_decomp_size)) == NULL) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n");
|
||||
return AVERROR(ENOMEM);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -602,7 +581,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
||||
if (zret != Z_OK) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret);
|
||||
av_freep(&c->decomp_buf);
|
||||
return AVERROR_INVALIDDATA;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@@ -63,7 +63,9 @@ static av_cold int aacPlus_encode_init(AVCodecContext *avctx)
|
||||
|
||||
aacplus_cfg->bitRate = avctx->bit_rate;
|
||||
aacplus_cfg->bandWidth = avctx->cutoff;
|
||||
aacplus_cfg->outputFormat = !(avctx->flags & CODEC_FLAG_GLOBAL_HEADER);
|
||||
if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) {
|
||||
aacplus_cfg->outputFormat = 0; //raw aac
|
||||
}
|
||||
aacplus_cfg->inputFormat = AACPLUS_INPUT_16BIT;
|
||||
if (!aacplusEncSetConfiguration(s->aacplus_handle, aacplus_cfg)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "libaacplus doesn't support this output format!\n");
|
||||
|
@@ -141,25 +141,18 @@ static int libgsm_decode_frame(AVCodecContext *avctx,
|
||||
AVPacket *avpkt) {
|
||||
const uint8_t *buf = avpkt->data;
|
||||
int buf_size = avpkt->size;
|
||||
int out_size = avctx->frame_size * av_get_bytes_per_sample(avctx->sample_fmt);
|
||||
|
||||
if (*data_size < out_size) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
*data_size = 0; /* In case of error */
|
||||
if(buf_size < avctx->block_align) return -1;
|
||||
switch(avctx->codec_id) {
|
||||
case CODEC_ID_GSM:
|
||||
if(gsm_decode(avctx->priv_data,buf,data)) return -1;
|
||||
*data_size = GSM_FRAME_SIZE*sizeof(int16_t);
|
||||
break;
|
||||
case CODEC_ID_GSM_MS:
|
||||
if(gsm_decode(avctx->priv_data,buf,data) ||
|
||||
gsm_decode(avctx->priv_data,buf+33,((int16_t*)data)+GSM_FRAME_SIZE)) return -1;
|
||||
*data_size = GSM_FRAME_SIZE*sizeof(int16_t)*2;
|
||||
}
|
||||
|
||||
*data_size = out_size;
|
||||
return avctx->block_align;
|
||||
}
|
||||
|
||||
|
@@ -101,14 +101,13 @@ static int encode_nals(AVCodecContext *ctx, uint8_t *buf, int size,
|
||||
}
|
||||
|
||||
static int X264_frame(AVCodecContext *ctx, uint8_t *buf,
|
||||
int orig_bufsize, void *data)
|
||||
int bufsize, void *data)
|
||||
{
|
||||
X264Context *x4 = ctx->priv_data;
|
||||
AVFrame *frame = data;
|
||||
x264_nal_t *nal;
|
||||
int nnal, i;
|
||||
x264_picture_t pic_out;
|
||||
int bufsize;
|
||||
|
||||
x264_picture_init( &x4->pic );
|
||||
x4->pic.img.i_csp = X264_CSP_I420;
|
||||
@@ -139,7 +138,6 @@ static int X264_frame(AVCodecContext *ctx, uint8_t *buf,
|
||||
}
|
||||
|
||||
do {
|
||||
bufsize = orig_bufsize;
|
||||
if (x264_encoder_encode(x4->enc, &nal, &nnal, frame? &x4->pic: NULL, &pic_out) < 0)
|
||||
return -1;
|
||||
|
||||
|
@@ -59,9 +59,6 @@ read_header:
|
||||
s->restart_count = 0;
|
||||
s->mjpb_skiptosod = 0;
|
||||
|
||||
if (buf_end - buf_ptr >= 1 << 28)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
init_get_bits(&hgb, buf_ptr, /*buf_size*/(buf_end - buf_ptr)*8);
|
||||
|
||||
skip_bits(&hgb, 32); /* reserved zeros */
|
||||
@@ -69,7 +66,7 @@ read_header:
|
||||
if (get_bits_long(&hgb, 32) != MKBETAG('m','j','p','g'))
|
||||
{
|
||||
av_log(avctx, AV_LOG_WARNING, "not mjpeg-b (bad fourcc)\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
return 0;
|
||||
}
|
||||
|
||||
field_size = get_bits_long(&hgb, 32); /* field size */
|
||||
@@ -112,8 +109,8 @@ read_header:
|
||||
av_log(avctx, AV_LOG_DEBUG, "sod offs: 0x%x\n", sod_offs);
|
||||
if (sos_offs)
|
||||
{
|
||||
init_get_bits(&s->gb, buf_ptr + sos_offs,
|
||||
8 * FFMIN(field_size, buf_end - buf_ptr - sos_offs));
|
||||
// init_get_bits(&s->gb, buf+sos_offs, (buf_end - (buf+sos_offs))*8);
|
||||
init_get_bits(&s->gb, buf_ptr+sos_offs, field_size*8);
|
||||
s->mjpb_skiptosod = (sod_offs - sos_offs - show_bits(&s->gb, 16));
|
||||
s->start_code = SOS;
|
||||
ff_mjpeg_decode_sos(s, NULL, NULL);
|
||||
@@ -145,7 +142,7 @@ read_header:
|
||||
picture->quality*= FF_QP2LAMBDA;
|
||||
}
|
||||
|
||||
return buf_size;
|
||||
return buf_ptr - buf;
|
||||
}
|
||||
|
||||
AVCodec ff_mjpegb_decoder = {
|
||||
|
@@ -950,12 +950,7 @@ static int output_data_internal(MLPDecodeContext *m, unsigned int substr,
|
||||
int32_t *data_32 = (int32_t*) data;
|
||||
int16_t *data_16 = (int16_t*) data;
|
||||
|
||||
if (m->avctx->channels != s->max_matrix_channel + 1) {
|
||||
av_log(m->avctx, AV_LOG_ERROR, "channel count mismatch\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (*data_size < m->avctx->channels * s->blockpos * (is32 ? 4 : 2))
|
||||
if (*data_size < (s->max_channel + 1) * s->blockpos * (is32 ? 4 : 2))
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < s->blockpos; i++) {
|
||||
|
@@ -52,7 +52,7 @@ static inline int sad_hpel_motion_search(MpegEncContext * s,
|
||||
int src_index, int ref_index,
|
||||
int size, int h);
|
||||
|
||||
static inline unsigned update_map_generation(MotionEstContext *c)
|
||||
static inline int update_map_generation(MotionEstContext *c)
|
||||
{
|
||||
c->map_generation+= 1<<(ME_MAP_MV_BITS*2);
|
||||
if(c->map_generation==0){
|
||||
@@ -1040,7 +1040,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
|
||||
/* intra / predictive decision */
|
||||
pix = c->src[0][0];
|
||||
sum = s->dsp.pix_sum(pix, s->linesize);
|
||||
varc = s->dsp.pix_norm1(pix, s->linesize) - (((unsigned)sum*sum)>>8) + 500;
|
||||
varc = s->dsp.pix_norm1(pix, s->linesize) - (((unsigned)(sum*sum))>>8) + 500;
|
||||
|
||||
pic->mb_mean[s->mb_stride * mb_y + mb_x] = (sum+128)>>8;
|
||||
pic->mb_var [s->mb_stride * mb_y + mb_x] = (varc+128)>>8;
|
||||
@@ -1202,7 +1202,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
|
||||
if((c->avctx->mb_cmp&0xFF)==FF_CMP_SSE){
|
||||
intra_score= varc - 500;
|
||||
}else{
|
||||
unsigned mean = (sum+128)>>8;
|
||||
int mean= (sum+128)>>8;
|
||||
mean*= 0x01010101;
|
||||
|
||||
for(i=0; i<16; i++){
|
||||
|
@@ -158,8 +158,9 @@ static int hpel_motion_search(MpegEncContext * s,
|
||||
const int b= score_map[(index+(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)]
|
||||
+ (mv_penalty[bx - pred_x] + mv_penalty[by+2 - pred_y])*c->penalty_factor;
|
||||
|
||||
unsigned key;
|
||||
unsigned map_generation= c->map_generation;
|
||||
#if 1
|
||||
int key;
|
||||
int map_generation= c->map_generation;
|
||||
#ifndef NDEBUG
|
||||
uint32_t *map= c->map;
|
||||
#endif
|
||||
@@ -171,6 +172,7 @@ static int hpel_motion_search(MpegEncContext * s,
|
||||
assert(map[(index+1)&(ME_MAP_SIZE-1)] == key);
|
||||
key= ((my)<<ME_MAP_MV_BITS) + (mx-1) + map_generation;
|
||||
assert(map[(index-1)&(ME_MAP_SIZE-1)] == key);
|
||||
#endif
|
||||
if(t<=b){
|
||||
CHECK_HALF_MV(0, 1, mx ,my-1)
|
||||
if(l<=r){
|
||||
@@ -278,7 +280,7 @@ static int qpel_motion_search(MpegEncContext * s,
|
||||
const int mx = *mx_ptr;
|
||||
const int my = *my_ptr;
|
||||
const int penalty_factor= c->sub_penalty_factor;
|
||||
const unsigned map_generation = c->map_generation;
|
||||
const int map_generation= c->map_generation;
|
||||
const int subpel_quality= c->avctx->me_subpel_quality;
|
||||
uint32_t *map= c->map;
|
||||
me_cmp_func cmpf, chroma_cmpf;
|
||||
@@ -495,7 +497,7 @@ static int qpel_motion_search(MpegEncContext * s,
|
||||
|
||||
#define CHECK_MV(x,y)\
|
||||
{\
|
||||
const unsigned key = ((y)<<ME_MAP_MV_BITS) + (x) + map_generation;\
|
||||
const int key= ((y)<<ME_MAP_MV_BITS) + (x) + map_generation;\
|
||||
const int index= (((y)<<ME_MAP_SHIFT) + (x))&(ME_MAP_SIZE-1);\
|
||||
assert((x) >= xmin);\
|
||||
assert((x) <= xmax);\
|
||||
@@ -523,7 +525,7 @@ static int qpel_motion_search(MpegEncContext * s,
|
||||
|
||||
#define CHECK_MV_DIR(x,y,new_dir)\
|
||||
{\
|
||||
const unsigned key = ((y)<<ME_MAP_MV_BITS) + (x) + map_generation;\
|
||||
const int key= ((y)<<ME_MAP_MV_BITS) + (x) + map_generation;\
|
||||
const int index= (((y)<<ME_MAP_SHIFT) + (x))&(ME_MAP_SIZE-1);\
|
||||
/*printf("check_mv_dir %d %d %d\n", x, y, new_dir);*/\
|
||||
if(map[index]!=key){\
|
||||
@@ -561,13 +563,13 @@ static av_always_inline int small_diamond_search(MpegEncContext * s, int *best,
|
||||
int next_dir=-1;
|
||||
LOAD_COMMON
|
||||
LOAD_COMMON2
|
||||
unsigned map_generation = c->map_generation;
|
||||
int map_generation= c->map_generation;
|
||||
|
||||
cmpf= s->dsp.me_cmp[size];
|
||||
chroma_cmpf= s->dsp.me_cmp[size+1];
|
||||
|
||||
{ /* ensure that the best point is in the MAP as h/qpel refinement needs it */
|
||||
const unsigned key = (best[1]<<ME_MAP_MV_BITS) + best[0] + map_generation;
|
||||
const int key= (best[1]<<ME_MAP_MV_BITS) + best[0] + map_generation;
|
||||
const int index= ((best[1]<<ME_MAP_SHIFT) + best[0])&(ME_MAP_SIZE-1);
|
||||
if(map[index]!=key){ //this will be executed only very rarey
|
||||
score_map[index]= cmp(s, best[0], best[1], 0, 0, size, h, ref_index, src_index, cmpf, chroma_cmpf, flags);
|
||||
@@ -603,7 +605,7 @@ static int funny_diamond_search(MpegEncContext * s, int *best, int dmin,
|
||||
int dia_size;
|
||||
LOAD_COMMON
|
||||
LOAD_COMMON2
|
||||
unsigned map_generation = c->map_generation;
|
||||
int map_generation= c->map_generation;
|
||||
|
||||
cmpf= s->dsp.me_cmp[size];
|
||||
chroma_cmpf= s->dsp.me_cmp[size+1];
|
||||
@@ -644,7 +646,7 @@ static int hex_search(MpegEncContext * s, int *best, int dmin,
|
||||
me_cmp_func cmpf, chroma_cmpf;
|
||||
LOAD_COMMON
|
||||
LOAD_COMMON2
|
||||
unsigned map_generation = c->map_generation;
|
||||
int map_generation= c->map_generation;
|
||||
int x,y,d;
|
||||
const int dec= dia_size & (dia_size-1);
|
||||
|
||||
@@ -678,7 +680,7 @@ static int l2s_dia_search(MpegEncContext * s, int *best, int dmin,
|
||||
me_cmp_func cmpf, chroma_cmpf;
|
||||
LOAD_COMMON
|
||||
LOAD_COMMON2
|
||||
unsigned map_generation = c->map_generation;
|
||||
int map_generation= c->map_generation;
|
||||
int x,y,i,d;
|
||||
int dia_size= c->dia_size&0xFF;
|
||||
const int dec= dia_size & (dia_size-1);
|
||||
@@ -716,7 +718,7 @@ static int umh_search(MpegEncContext * s, int *best, int dmin,
|
||||
me_cmp_func cmpf, chroma_cmpf;
|
||||
LOAD_COMMON
|
||||
LOAD_COMMON2
|
||||
unsigned map_generation = c->map_generation;
|
||||
int map_generation= c->map_generation;
|
||||
int x,y,x2,y2, i, j, d;
|
||||
const int dia_size= c->dia_size&0xFE;
|
||||
static const int hex[16][2]={{-4,-2}, {-4,-1}, {-4, 0}, {-4, 1}, {-4, 2},
|
||||
@@ -763,7 +765,7 @@ static int full_search(MpegEncContext * s, int *best, int dmin,
|
||||
me_cmp_func cmpf, chroma_cmpf;
|
||||
LOAD_COMMON
|
||||
LOAD_COMMON2
|
||||
unsigned map_generation = c->map_generation;
|
||||
int map_generation= c->map_generation;
|
||||
int x,y, d;
|
||||
const int dia_size= c->dia_size&0xFF;
|
||||
|
||||
@@ -792,7 +794,7 @@ static int full_search(MpegEncContext * s, int *best, int dmin,
|
||||
|
||||
#define SAB_CHECK_MV(ax,ay)\
|
||||
{\
|
||||
const unsigned key = ((ay)<<ME_MAP_MV_BITS) + (ax) + map_generation;\
|
||||
const int key= ((ay)<<ME_MAP_MV_BITS) + (ax) + map_generation;\
|
||||
const int index= (((ay)<<ME_MAP_SHIFT) + (ax))&(ME_MAP_SIZE-1);\
|
||||
/*printf("sab check %d %d\n", ax, ay);*/\
|
||||
if(map[index]!=key){\
|
||||
@@ -831,7 +833,7 @@ static int sab_diamond_search(MpegEncContext * s, int *best, int dmin,
|
||||
int i, j;
|
||||
LOAD_COMMON
|
||||
LOAD_COMMON2
|
||||
unsigned map_generation = c->map_generation;
|
||||
int map_generation= c->map_generation;
|
||||
|
||||
cmpf= s->dsp.me_cmp[size];
|
||||
chroma_cmpf= s->dsp.me_cmp[size+1];
|
||||
@@ -916,7 +918,7 @@ static int var_diamond_search(MpegEncContext * s, int *best, int dmin,
|
||||
int dia_size;
|
||||
LOAD_COMMON
|
||||
LOAD_COMMON2
|
||||
unsigned map_generation = c->map_generation;
|
||||
int map_generation= c->map_generation;
|
||||
|
||||
cmpf= s->dsp.me_cmp[size];
|
||||
chroma_cmpf= s->dsp.me_cmp[size+1];
|
||||
@@ -1008,7 +1010,7 @@ static av_always_inline int epzs_motion_search_internal(MpegEncContext * s, int
|
||||
int d; ///< the score (cmp + penalty) of any given mv
|
||||
int dmin; /*!< the best value of d, i.e. the score
|
||||
corresponding to the mv stored in best[]. */
|
||||
unsigned map_generation;
|
||||
int map_generation;
|
||||
int penalty_factor;
|
||||
const int ref_mv_stride= s->mb_stride; //pass as arg FIXME
|
||||
const int ref_mv_xy= s->mb_x + s->mb_y*ref_mv_stride; //add to last_mv beforepassing FIXME
|
||||
@@ -1136,7 +1138,7 @@ static int epzs_motion_search4(MpegEncContext * s,
|
||||
MotionEstContext * const c= &s->me;
|
||||
int best[2]={0, 0};
|
||||
int d, dmin;
|
||||
unsigned map_generation;
|
||||
int map_generation;
|
||||
const int penalty_factor= c->penalty_factor;
|
||||
const int size=1;
|
||||
const int h=8;
|
||||
@@ -1196,7 +1198,7 @@ static int epzs_motion_search2(MpegEncContext * s,
|
||||
MotionEstContext * const c= &s->me;
|
||||
int best[2]={0, 0};
|
||||
int d, dmin;
|
||||
unsigned map_generation;
|
||||
int map_generation;
|
||||
const int penalty_factor= c->penalty_factor;
|
||||
const int size=0; //FIXME pass as arg
|
||||
const int h=8;
|
||||
|
@@ -55,11 +55,6 @@ static av_cold int mp_decode_init(AVCodecContext *avctx)
|
||||
int w4 = (avctx->width + 3) & ~3;
|
||||
int h4 = (avctx->height + 3) & ~3;
|
||||
|
||||
if(avctx->extradata_size < 2){
|
||||
av_log(avctx, AV_LOG_ERROR, "extradata too small\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
motionpixels_tableinit();
|
||||
mp->avctx = avctx;
|
||||
dsputil_init(&mp->dsp, avctx);
|
||||
@@ -196,13 +191,10 @@ static void mp_decode_line(MotionPixelsContext *mp, GetBitContext *gb, int y)
|
||||
p = mp_get_yuv_from_rgb(mp, x - 1, y);
|
||||
} else {
|
||||
p.y += mp_gradient(mp, 0, mp_get_vlc(mp, gb));
|
||||
p.y = av_clip(p.y, 0, 31);
|
||||
if ((x & 3) == 0) {
|
||||
if ((y & 3) == 0) {
|
||||
p.v += mp_gradient(mp, 1, mp_get_vlc(mp, gb));
|
||||
p.v = av_clip(p.v, -32, 31);
|
||||
p.u += mp_gradient(mp, 2, mp_get_vlc(mp, gb));
|
||||
p.u = av_clip(p.u, -32, 31);
|
||||
mp->hpt[((y / 4) * mp->avctx->width + x) / 4] = p;
|
||||
} else {
|
||||
p.v = mp->hpt[((y / 4) * mp->avctx->width + x) / 4].v;
|
||||
@@ -226,12 +218,9 @@ static void mp_decode_frame_helper(MotionPixelsContext *mp, GetBitContext *gb)
|
||||
p = mp_get_yuv_from_rgb(mp, 0, y);
|
||||
} else {
|
||||
p.y += mp_gradient(mp, 0, mp_get_vlc(mp, gb));
|
||||
p.y = av_clip(p.y, 0, 31);
|
||||
if ((y & 3) == 0) {
|
||||
p.v += mp_gradient(mp, 1, mp_get_vlc(mp, gb));
|
||||
p.v = av_clip(p.v, -32, 31);
|
||||
p.u += mp_gradient(mp, 2, mp_get_vlc(mp, gb));
|
||||
p.u = av_clip(p.u, -32, 31);
|
||||
}
|
||||
mp->vpt[y] = p;
|
||||
mp_set_rgb_from_yuv(mp, 0, y, &p);
|
||||
|
@@ -197,19 +197,12 @@ static int mpc7_decode_frame(AVCodecContext * avctx,
|
||||
int i, ch;
|
||||
int mb = -1;
|
||||
Band *bands = c->bands;
|
||||
int off, out_size;
|
||||
int off;
|
||||
int bits_used, bits_avail;
|
||||
|
||||
memset(bands, 0, sizeof(bands));
|
||||
if(buf_size <= 4){
|
||||
av_log(avctx, AV_LOG_ERROR, "Too small buffer passed (%i bytes)\n", buf_size);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
out_size = (buf[1] ? c->lastframelen : MPC_FRAME_SIZE) * 4;
|
||||
if (*data_size < out_size) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
bits = av_malloc(((buf_size - 1) & ~3) + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||
@@ -284,7 +277,7 @@ static int mpc7_decode_frame(AVCodecContext * avctx,
|
||||
*data_size = 0;
|
||||
return buf_size;
|
||||
}
|
||||
*data_size = out_size;
|
||||
*data_size = (buf[1] ? c->lastframelen : MPC_FRAME_SIZE) * 4;
|
||||
|
||||
return buf_size;
|
||||
}
|
||||
|
@@ -138,8 +138,7 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx)
|
||||
c->frames = 1 << (get_bits(&gb, 3) * 2);
|
||||
|
||||
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
|
||||
avctx->channel_layout = (channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
|
||||
avctx->channels = channels;
|
||||
avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
|
||||
|
||||
if(vlc_initialized) return 0;
|
||||
av_log(avctx, AV_LOG_DEBUG, "Initing VLC\n");
|
||||
@@ -244,16 +243,10 @@ static int mpc8_decode_frame(AVCodecContext * avctx,
|
||||
GetBitContext gb2, *gb = &gb2;
|
||||
int i, j, k, ch, cnt, res, t;
|
||||
Band *bands = c->bands;
|
||||
int off, out_size;
|
||||
int off;
|
||||
int maxband, keyframe;
|
||||
int last[2];
|
||||
|
||||
out_size = MPC_FRAME_SIZE * 2 * avctx->channels;
|
||||
if (*data_size < out_size) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
keyframe = c->cur_frame == 0;
|
||||
|
||||
if(keyframe){
|
||||
@@ -411,7 +404,7 @@ static int mpc8_decode_frame(AVCodecContext * avctx,
|
||||
c->last_bits_used = get_bits_count(gb);
|
||||
if(c->cur_frame >= c->frames)
|
||||
c->cur_frame = 0;
|
||||
*data_size = out_size;
|
||||
*data_size = MPC_FRAME_SIZE * 2 * avctx->channels;
|
||||
|
||||
return c->cur_frame ? c->last_bits_used >> 3 : buf_size;
|
||||
}
|
||||
|
@@ -2475,10 +2475,18 @@ static int decode_chunks(AVCodecContext *avctx,
|
||||
/* Skip P-frames if we do not have a reference frame or we have an invalid header. */
|
||||
if(s2->pict_type==AV_PICTURE_TYPE_P && !s->sync) break;
|
||||
}
|
||||
#if FF_API_HURRY_UP
|
||||
/* Skip B-frames if we are in a hurry. */
|
||||
if(avctx->hurry_up && s2->pict_type==FF_B_TYPE) break;
|
||||
#endif
|
||||
if( (avctx->skip_frame >= AVDISCARD_NONREF && s2->pict_type==AV_PICTURE_TYPE_B)
|
||||
||(avctx->skip_frame >= AVDISCARD_NONKEY && s2->pict_type!=AV_PICTURE_TYPE_I)
|
||||
|| avctx->skip_frame >= AVDISCARD_ALL)
|
||||
break;
|
||||
#if FF_API_HURRY_UP
|
||||
/* Skip everything if we are in a hurry>=5. */
|
||||
if(avctx->hurry_up>=5) break;
|
||||
#endif
|
||||
|
||||
if (!s->mpeg_enc_ctx_allocated) break;
|
||||
|
||||
|
@@ -27,7 +27,6 @@
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "dsputil.h"
|
||||
#include "mathops.h"
|
||||
#include "mpegvideo.h"
|
||||
|
||||
#include "mpeg12.h"
|
||||
@@ -682,7 +681,8 @@ static void mpeg1_encode_motion(MpegEncContext *s, int val, int f_or_b_code)
|
||||
int bit_size = f_or_b_code - 1;
|
||||
int range = 1 << bit_size;
|
||||
/* modulo encoding */
|
||||
val = sign_extend(val, 5 + bit_size);
|
||||
int l= INT_BIT - 5 - bit_size;
|
||||
val= (val<<l)>>l;
|
||||
|
||||
if (val >= 0) {
|
||||
val--;
|
||||
|
@@ -1801,8 +1801,8 @@ static int decode_frame(AVCodecContext * avctx,
|
||||
avctx->bit_rate = s->bit_rate;
|
||||
avctx->sub_id = s->layer;
|
||||
|
||||
if (*data_size < avctx->frame_size * avctx->channels * sizeof(OUT_INT))
|
||||
return AVERROR(EINVAL);
|
||||
if(*data_size < 1152*avctx->channels*sizeof(OUT_INT))
|
||||
return -1;
|
||||
*data_size = 0;
|
||||
|
||||
if(s->frame_size<=0 || s->frame_size > buf_size){
|
||||
@@ -1870,9 +1870,6 @@ static int decode_frame_adu(AVCodecContext * avctx,
|
||||
avctx->bit_rate = s->bit_rate;
|
||||
avctx->sub_id = s->layer;
|
||||
|
||||
if (*data_size < avctx->frame_size * avctx->channels * sizeof(OUT_INT))
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
s->frame_size = len;
|
||||
|
||||
if (avctx->parse_only) {
|
||||
|
@@ -366,8 +366,8 @@ static int init_duplicate_context(MpegEncContext *s, MpegEncContext *base){
|
||||
int i;
|
||||
|
||||
// edge emu needs blocksize + filter length - 1 (=17x17 for halfpel / 21x21 for h264)
|
||||
FF_ALLOCZ_OR_GOTO(s->avctx, s->edge_emu_buffer, (s->width+64)*2*21*2*2, fail); //(width + edge + align)*interlaced*MBsize*tolerance
|
||||
|
||||
FF_ALLOCZ_OR_GOTO(s->avctx, s->allocated_edge_emu_buffer, (s->width+64)*2*21*2*2, fail); //(width + edge + align)*interlaced*MBsize*tolerance
|
||||
s->edge_emu_buffer= s->allocated_edge_emu_buffer + (s->width+64)*2*21*2;
|
||||
|
||||
//FIXME should be linesize instead of s->width*2 but that is not known before get_buffer()
|
||||
FF_ALLOCZ_OR_GOTO(s->avctx, s->me.scratchpad, (s->width+64)*4*16*2*sizeof(uint8_t), fail)
|
||||
@@ -405,7 +405,7 @@ fail:
|
||||
static void free_duplicate_context(MpegEncContext *s){
|
||||
if(s==NULL) return;
|
||||
|
||||
av_freep(&s->edge_emu_buffer);
|
||||
av_freep(&s->allocated_edge_emu_buffer); s->edge_emu_buffer= NULL;
|
||||
av_freep(&s->me.scratchpad);
|
||||
s->me.temp=
|
||||
s->rd_scratchpad=
|
||||
@@ -422,6 +422,7 @@ static void free_duplicate_context(MpegEncContext *s){
|
||||
|
||||
static void backup_duplicate_context(MpegEncContext *bak, MpegEncContext *src){
|
||||
#define COPY(a) bak->a= src->a
|
||||
COPY(allocated_edge_emu_buffer);
|
||||
COPY(edge_emu_buffer);
|
||||
COPY(me.scratchpad);
|
||||
COPY(me.temp);
|
||||
@@ -1138,6 +1139,9 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
|
||||
}
|
||||
}
|
||||
|
||||
#if FF_API_HURRY_UP
|
||||
s->hurry_up= s->avctx->hurry_up;
|
||||
#endif
|
||||
s->error_recognition= avctx->error_recognition;
|
||||
|
||||
/* set dequantizer, we can't do it during init as it might change for mpeg4
|
||||
@@ -2147,6 +2151,9 @@ void MPV_decode_mb_internal(MpegEncContext *s, DCTELEM block[12][64],
|
||||
}
|
||||
|
||||
/* skip dequant / idct if we are really late ;) */
|
||||
#if FF_API_HURRY_UP
|
||||
if(s->hurry_up>1) goto skip_idct;
|
||||
#endif
|
||||
if(s->avctx->skip_idct){
|
||||
if( (s->avctx->skip_idct >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B)
|
||||
||(s->avctx->skip_idct >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I)
|
||||
@@ -2301,15 +2308,12 @@ void ff_draw_horiz_band(MpegEncContext *s, int y, int h){
|
||||
|
||||
edge_h= FFMIN(h, s->v_edge_pos - y);
|
||||
|
||||
s->dsp.draw_edges(s->current_picture_ptr->data[0] + y *s->linesize,
|
||||
s->linesize, s->h_edge_pos, edge_h,
|
||||
EDGE_WIDTH, EDGE_WIDTH, sides);
|
||||
s->dsp.draw_edges(s->current_picture_ptr->data[1] + (y>>vshift)*s->uvlinesize,
|
||||
s->uvlinesize, s->h_edge_pos>>hshift, edge_h>>vshift,
|
||||
EDGE_WIDTH>>hshift, EDGE_WIDTH>>vshift, sides);
|
||||
s->dsp.draw_edges(s->current_picture_ptr->data[2] + (y>>vshift)*s->uvlinesize,
|
||||
s->uvlinesize, s->h_edge_pos>>hshift, edge_h>>vshift,
|
||||
EDGE_WIDTH>>hshift, EDGE_WIDTH>>vshift, sides);
|
||||
s->dsp.draw_edges(s->current_picture_ptr->data[0] + y *s->linesize , s->linesize,
|
||||
s->h_edge_pos , edge_h , EDGE_WIDTH , EDGE_WIDTH , sides);
|
||||
s->dsp.draw_edges(s->current_picture_ptr->data[1] + (y>>vshift)*s->uvlinesize, s->uvlinesize,
|
||||
s->h_edge_pos>>hshift, edge_h>>hshift, EDGE_WIDTH>>hshift, EDGE_WIDTH>>vshift, sides);
|
||||
s->dsp.draw_edges(s->current_picture_ptr->data[2] + (y>>vshift)*s->uvlinesize, s->uvlinesize,
|
||||
s->h_edge_pos>>hshift, edge_h>>hshift, EDGE_WIDTH>>hshift, EDGE_WIDTH>>vshift, sides);
|
||||
}
|
||||
|
||||
h= FFMIN(h, s->avctx->height - y);
|
||||
|
@@ -153,7 +153,7 @@ typedef struct MotionEstContext{
|
||||
int best_bits;
|
||||
uint32_t *map; ///< map to avoid duplicate evaluations
|
||||
uint32_t *score_map; ///< map to store the scores
|
||||
unsigned map_generation;
|
||||
int map_generation;
|
||||
int pre_penalty_factor;
|
||||
int penalty_factor; /*!< an estimate of the bits required to
|
||||
code a given mv value, e.g. (1,0) takes
|
||||
@@ -317,7 +317,8 @@ typedef struct MpegEncContext {
|
||||
uint8_t *mbintra_table; ///< used to avoid setting {ac, dc, cbp}-pred stuff to zero on inter MB decoding
|
||||
uint8_t *cbp_table; ///< used to store cbp, ac_pred for partitioned decoding
|
||||
uint8_t *pred_dir_table; ///< used to store pred_dir for partitioned decoding
|
||||
uint8_t *edge_emu_buffer; ///< temporary buffer for if MVs point to out-of-frame data
|
||||
uint8_t *allocated_edge_emu_buffer;
|
||||
uint8_t *edge_emu_buffer; ///< points into the middle of allocated_edge_emu_buffer
|
||||
uint8_t *rd_scratchpad; ///< scratchpad for rate distortion mb decision
|
||||
uint8_t *obmc_scratchpad;
|
||||
uint8_t *b_scratchpad; ///< scratchpad used for writing into write only buffers
|
||||
@@ -391,6 +392,11 @@ typedef struct MpegEncContext {
|
||||
int no_rounding; /**< apply no rounding to motion compensation (MPEG4, msmpeg4, ...)
|
||||
for b-frames rounding mode is always 0 */
|
||||
|
||||
#if FF_API_HURRY_UP
|
||||
int hurry_up; /**< when set to 1 during decoding, b frames will be skipped
|
||||
when set to 2 idct/dequant will be skipped too */
|
||||
#endif
|
||||
|
||||
/* macroblock layer */
|
||||
int mb_x, mb_y;
|
||||
int mb_skip_run;
|
||||
|
@@ -725,7 +725,7 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
|
||||
0, 0, 0,
|
||||
ref_picture, pix_op, qpix_op,
|
||||
s->mv[dir][0][0], s->mv[dir][0][1], 16);
|
||||
}else if(!is_mpeg12 && (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) && s->mspel && s->codec_id == CODEC_ID_WMV2){
|
||||
}else if(!is_mpeg12 && (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) && s->mspel){
|
||||
ff_mspel_motion(s, dest_y, dest_cb, dest_cr,
|
||||
ref_picture, pix_op,
|
||||
s->mv[dir][0][0], s->mv[dir][0][1], 16);
|
||||
|
@@ -973,7 +973,7 @@ static int estimate_best_b_count(MpegEncContext *s){
|
||||
c->time_base= s->avctx->time_base;
|
||||
c->max_b_frames= s->max_b_frames;
|
||||
|
||||
if (avcodec_open2(c, codec, NULL) < 0)
|
||||
if (avcodec_open(c, codec) < 0)
|
||||
return -1;
|
||||
|
||||
for(i=0; i<s->max_b_frames+2; i++){
|
||||
@@ -2007,7 +2007,7 @@ static int mb_var_thread(AVCodecContext *c, void *arg){
|
||||
int varc;
|
||||
int sum = s->dsp.pix_sum(pix, s->linesize);
|
||||
|
||||
varc = (s->dsp.pix_norm1(pix, s->linesize) - (((unsigned)sum*sum)>>8) + 500 + 128)>>8;
|
||||
varc = (s->dsp.pix_norm1(pix, s->linesize) - (((unsigned)(sum*sum))>>8) + 500 + 128)>>8;
|
||||
|
||||
s->current_picture.mb_var [s->mb_stride * mb_y + mb_x] = varc;
|
||||
s->current_picture.mb_mean[s->mb_stride * mb_y + mb_x] = (sum+128)>>8;
|
||||
|
@@ -26,6 +26,9 @@
|
||||
* http://www.pcisys.net/~melanson/codecs/
|
||||
*
|
||||
* The MS RLE decoder outputs PAL8 colorspace data.
|
||||
*
|
||||
* Note that this decoder expects the palette colors from the end of the
|
||||
* BITMAPINFO header passed through palctrl.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -43,7 +46,6 @@ typedef struct MsrleContext {
|
||||
const unsigned char *buf;
|
||||
int size;
|
||||
|
||||
uint32_t pal[256];
|
||||
} MsrleContext;
|
||||
|
||||
static av_cold int msrle_decode_init(AVCodecContext *avctx)
|
||||
@@ -93,16 +95,13 @@ static int msrle_decode_frame(AVCodecContext *avctx,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (avctx->bits_per_coded_sample > 1 && avctx->bits_per_coded_sample <= 8) {
|
||||
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
|
||||
|
||||
if (pal) {
|
||||
s->frame.palette_has_changed = 1;
|
||||
memcpy(s->pal, pal, AVPALETTE_SIZE);
|
||||
}
|
||||
|
||||
if (s->avctx->palctrl) {
|
||||
/* make the palette available */
|
||||
memcpy(s->frame.data[1], s->pal, AVPALETTE_SIZE);
|
||||
memcpy(s->frame.data[1], s->avctx->palctrl->palette, AVPALETTE_SIZE);
|
||||
if (s->avctx->palctrl->palette_changed) {
|
||||
s->frame.palette_has_changed = 1;
|
||||
s->avctx->palctrl->palette_changed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* FIXME how to correctly detect RLE ??? */
|
||||
|
@@ -25,6 +25,9 @@
|
||||
* For more information about the MS Video-1 format, visit:
|
||||
* http://www.pcisys.net/~melanson/codecs/
|
||||
*
|
||||
* This decoder outputs either PAL8 or RGB555 data, depending on the
|
||||
* whether a RGB palette was passed through palctrl;
|
||||
* if it's present, then the data is PAL8; RGB555 otherwise.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -52,7 +55,6 @@ typedef struct Msvideo1Context {
|
||||
|
||||
int mode_8bit; /* if it's not 8-bit, it's 16-bit */
|
||||
|
||||
uint32_t pal[256];
|
||||
} Msvideo1Context;
|
||||
|
||||
static av_cold int msvideo1_decode_init(AVCodecContext *avctx)
|
||||
@@ -62,7 +64,7 @@ static av_cold int msvideo1_decode_init(AVCodecContext *avctx)
|
||||
s->avctx = avctx;
|
||||
|
||||
/* figure out the colorspace based on the presence of a palette */
|
||||
if (s->avctx->bits_per_coded_sample == 8) {
|
||||
if (s->avctx->palctrl) {
|
||||
s->mode_8bit = 1;
|
||||
avctx->pix_fmt = PIX_FMT_PAL8;
|
||||
} else {
|
||||
@@ -172,8 +174,13 @@ static void msvideo1_decode_8bit(Msvideo1Context *s)
|
||||
}
|
||||
|
||||
/* make the palette available on the way out */
|
||||
if (s->avctx->pix_fmt == PIX_FMT_PAL8)
|
||||
memcpy(s->frame.data[1], s->pal, AVPALETTE_SIZE);
|
||||
if (s->avctx->pix_fmt == PIX_FMT_PAL8) {
|
||||
memcpy(s->frame.data[1], s->avctx->palctrl->palette, AVPALETTE_SIZE);
|
||||
if (s->avctx->palctrl->palette_changed) {
|
||||
s->frame.palette_has_changed = 1;
|
||||
s->avctx->palctrl->palette_changed = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void msvideo1_decode_16bit(Msvideo1Context *s)
|
||||
@@ -303,15 +310,6 @@ static int msvideo1_decode_frame(AVCodecContext *avctx,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (s->mode_8bit) {
|
||||
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
|
||||
|
||||
if (pal) {
|
||||
memcpy(s->pal, pal, AVPALETTE_SIZE);
|
||||
s->frame.palette_has_changed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (s->mode_8bit)
|
||||
msvideo1_decode_8bit(s);
|
||||
else
|
||||
|
@@ -157,26 +157,19 @@ static int decode_tag(AVCodecContext * avctx,
|
||||
int buf_size = avpkt->size;
|
||||
NellyMoserDecodeContext *s = avctx->priv_data;
|
||||
int data_max = *data_size;
|
||||
int blocks, i, block_size;
|
||||
int blocks, i;
|
||||
int16_t* samples;
|
||||
*data_size = 0;
|
||||
samples = (int16_t*)data;
|
||||
|
||||
if (buf_size < avctx->block_align) {
|
||||
*data_size = 0;
|
||||
if (buf_size < avctx->block_align)
|
||||
return buf_size;
|
||||
}
|
||||
|
||||
if (buf_size % 64) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Tag size %d.\n", buf_size);
|
||||
*data_size = 0;
|
||||
return buf_size;
|
||||
}
|
||||
block_size = NELLY_SAMPLES * av_get_bytes_per_sample(avctx->sample_fmt);
|
||||
blocks = FFMIN(buf_size / 64, *data_size / block_size);
|
||||
if (blocks <= 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
blocks = buf_size / 64;
|
||||
/* Normal numbers of blocks for sample rates:
|
||||
* 8000 Hz - 1
|
||||
* 11025 Hz - 2
|
||||
@@ -190,8 +183,8 @@ static int decode_tag(AVCodecContext * avctx,
|
||||
return i > 0 ? i * NELLY_BLOCK_LEN : -1;
|
||||
nelly_decode_block(s, &buf[i*NELLY_BLOCK_LEN], s->float_buf);
|
||||
s->fmt_conv.float_to_int16(&samples[i*NELLY_SAMPLES], s->float_buf, NELLY_SAMPLES);
|
||||
*data_size += NELLY_SAMPLES*sizeof(int16_t);
|
||||
}
|
||||
*data_size = blocks * block_size;
|
||||
|
||||
return buf_size;
|
||||
}
|
||||
|
@@ -20,7 +20,6 @@
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "libavutil/bswap.h"
|
||||
#include "libavutil/lzo.h"
|
||||
@@ -113,23 +112,19 @@ static int codec_reinit(AVCodecContext *avctx, int width, int height, int qualit
|
||||
if (quality >= 0)
|
||||
get_quant_quality(c, quality);
|
||||
if (width != c->width || height != c->height) {
|
||||
// also reserve space for a possible additional header
|
||||
int buf_size = 24 + height * width * 3 / 2 + AV_LZO_OUTPUT_PADDING;
|
||||
if (av_image_check_size(height, width, 0, avctx) < 0 ||
|
||||
buf_size > INT_MAX/8)
|
||||
return -1;
|
||||
if (av_image_check_size(height, width, 0, avctx) < 0)
|
||||
return 0;
|
||||
avctx->width = c->width = width;
|
||||
avctx->height = c->height = height;
|
||||
av_fast_malloc(&c->decomp_buf, &c->decomp_size, buf_size);
|
||||
av_fast_malloc(&c->decomp_buf, &c->decomp_size, c->height * c->width * 3 / 2);
|
||||
if (!c->decomp_buf) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n");
|
||||
return AVERROR(ENOMEM);
|
||||
return 0;
|
||||
}
|
||||
rtjpeg_decode_init(&c->rtj, &c->dsp, c->width, c->height, c->lq, c->cq);
|
||||
return 1;
|
||||
} else if (quality != c->quality)
|
||||
rtjpeg_decode_init(&c->rtj, &c->dsp, c->width, c->height, c->lq, c->cq);
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
|
||||
@@ -140,7 +135,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
|
||||
AVFrame *picture = data;
|
||||
int orig_size = buf_size;
|
||||
int keyframe;
|
||||
int size_change = 0;
|
||||
int result;
|
||||
enum {NUV_UNCOMPRESSED = '0', NUV_RTJPEG = '1',
|
||||
NUV_RTJPEG_IN_LZO = '2', NUV_LZO = '3',
|
||||
@@ -178,19 +172,18 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
|
||||
default:
|
||||
keyframe = 1; break;
|
||||
}
|
||||
retry:
|
||||
// skip rest of the frameheader.
|
||||
buf = &buf[12];
|
||||
buf_size -= 12;
|
||||
if (comptype == NUV_RTJPEG_IN_LZO || comptype == NUV_LZO) {
|
||||
int outlen = c->decomp_size - AV_LZO_OUTPUT_PADDING, inlen = buf_size;
|
||||
int outlen = c->decomp_size, inlen = buf_size;
|
||||
if (av_lzo1x_decode(c->decomp_buf, &outlen, buf, &inlen))
|
||||
av_log(avctx, AV_LOG_ERROR, "error during lzo decompression\n");
|
||||
buf = c->decomp_buf;
|
||||
buf_size = c->decomp_size - AV_LZO_OUTPUT_PADDING;
|
||||
buf_size = c->decomp_size;
|
||||
}
|
||||
if (c->codec_frameheader) {
|
||||
int w, h, q, res;
|
||||
int w, h, q;
|
||||
if (buf_size < 12) {
|
||||
av_log(avctx, AV_LOG_ERROR, "invalid nuv video frame\n");
|
||||
return -1;
|
||||
@@ -198,20 +191,13 @@ retry:
|
||||
w = AV_RL16(&buf[6]);
|
||||
h = AV_RL16(&buf[8]);
|
||||
q = buf[10];
|
||||
res = codec_reinit(avctx, w, h, q);
|
||||
if (res < 0)
|
||||
return res;
|
||||
if (res) {
|
||||
buf = avpkt->data;
|
||||
buf_size = avpkt->size;
|
||||
size_change = 1;
|
||||
goto retry;
|
||||
}
|
||||
if (!codec_reinit(avctx, w, h, q))
|
||||
return -1;
|
||||
buf = &buf[12];
|
||||
buf_size -= 12;
|
||||
}
|
||||
|
||||
if ((size_change || keyframe) && c->pic.data[0])
|
||||
if (keyframe && c->pic.data[0])
|
||||
avctx->release_buffer(avctx, &c->pic);
|
||||
c->pic.reference = 3;
|
||||
c->pic.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_READABLE |
|
||||
@@ -273,7 +259,7 @@ static av_cold int decode_init(AVCodecContext *avctx) {
|
||||
if (avctx->extradata_size)
|
||||
get_quant(avctx, c, avctx->extradata, avctx->extradata_size);
|
||||
dsputil_init(&c->dsp, avctx);
|
||||
if (codec_reinit(avctx, avctx->width, avctx->height, -1) < 0)
|
||||
if (!codec_reinit(avctx, avctx->width, avctx->height, -1))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
89
libavcodec/opt.c
Normal file
89
libavcodec/opt.c
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* AVOptions ABI compatibility wrapper
|
||||
* Copyright (c) 2010 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "opt.h"
|
||||
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 53 && CONFIG_SHARED && HAVE_SYMVER
|
||||
|
||||
FF_SYMVER(const AVOption *, av_find_opt, (void *obj, const char *name, const char *unit, int mask, int flags), "LIBAVCODEC_52"){
|
||||
return av_find_opt(obj, name, unit, mask, flags);
|
||||
}
|
||||
FF_SYMVER(int, av_set_string3, (void *obj, const char *name, const char *val, int alloc, const AVOption **o_out), "LIBAVCODEC_52"){
|
||||
return av_set_string3(obj, name, val, alloc, o_out);
|
||||
}
|
||||
FF_SYMVER(const AVOption *, av_set_double, (void *obj, const char *name, double n), "LIBAVCODEC_52"){
|
||||
return av_set_double(obj, name, n);
|
||||
}
|
||||
FF_SYMVER(const AVOption *, av_set_q, (void *obj, const char *name, AVRational n), "LIBAVCODEC_52"){
|
||||
return av_set_q(obj, name, n);
|
||||
}
|
||||
FF_SYMVER(const AVOption *, av_set_int, (void *obj, const char *name, int64_t n), "LIBAVCODEC_52"){
|
||||
return av_set_int(obj, name, n);
|
||||
}
|
||||
FF_SYMVER(double, av_get_double, (void *obj, const char *name, const AVOption **o_out), "LIBAVCODEC_52"){
|
||||
return av_get_double(obj, name, o_out);
|
||||
}
|
||||
FF_SYMVER(AVRational, av_get_q, (void *obj, const char *name, const AVOption **o_out), "LIBAVCODEC_52"){
|
||||
return av_get_q(obj, name, o_out);
|
||||
}
|
||||
FF_SYMVER(int64_t, av_get_int, (void *obj, const char *name, const AVOption **o_out), "LIBAVCODEC_52"){
|
||||
return av_get_int(obj, name, o_out);
|
||||
}
|
||||
FF_SYMVER(const char *, av_get_string, (void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len), "LIBAVCODEC_52"){
|
||||
return av_get_string(obj, name, o_out, buf, buf_len);
|
||||
}
|
||||
FF_SYMVER(const AVOption *, av_next_option, (void *obj, const AVOption *last), "LIBAVCODEC_52"){
|
||||
return av_next_option(obj, last);
|
||||
}
|
||||
FF_SYMVER(int, av_opt_show2, (void *obj, void *av_log_obj, int req_flags, int rej_flags), "LIBAVCODEC_52"){
|
||||
return av_opt_show2(obj, av_log_obj, req_flags, rej_flags);
|
||||
}
|
||||
FF_SYMVER(void, av_opt_set_defaults, (void *s), "LIBAVCODEC_52"){
|
||||
return av_opt_set_defaults(s);
|
||||
}
|
||||
FF_SYMVER(void, av_opt_set_defaults2, (void *s, int mask, int flags), "LIBAVCODEC_52"){
|
||||
return av_opt_set_defaults2(s, mask, flags);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if FF_API_SET_STRING_OLD
|
||||
const AVOption *av_set_string2(void *obj, const char *name, const char *val, int alloc){
|
||||
const AVOption *o;
|
||||
if (av_set_string3(obj, name, val, alloc, &o) < 0)
|
||||
return NULL;
|
||||
return o;
|
||||
}
|
||||
|
||||
const AVOption *av_set_string(void *obj, const char *name, const char *val){
|
||||
const AVOption *o;
|
||||
if (av_set_string3(obj, name, val, 0, &o) < 0)
|
||||
return NULL;
|
||||
return o;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if FF_API_OPT_SHOW
|
||||
int av_opt_show(void *obj, void *av_log_obj){
|
||||
return av_opt_show2(obj, av_log_obj,
|
||||
AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM, 0);
|
||||
}
|
||||
#endif
|
@@ -1,18 +1,21 @@
|
||||
/*
|
||||
* This file is part of Libav.
|
||||
* AVOptions
|
||||
* copyright (c) 2005 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg 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,
|
||||
* FFmpeg 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
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
@@ -25,10 +28,34 @@
|
||||
#ifndef AVCODEC_OPT_H
|
||||
#define AVCODEC_OPT_H
|
||||
|
||||
#include "libavcodec/version.h"
|
||||
/**
|
||||
* @file
|
||||
* AVOptions
|
||||
*/
|
||||
|
||||
#if FF_API_OPT_H
|
||||
#include "libavutil/rational.h"
|
||||
#include "avcodec.h"
|
||||
#include "libavutil/opt.h"
|
||||
|
||||
#if FF_API_SET_STRING_OLD
|
||||
/**
|
||||
* @see av_set_string2()
|
||||
*/
|
||||
attribute_deprecated const AVOption *av_set_string(void *obj, const char *name, const char *val);
|
||||
|
||||
/**
|
||||
* @return a pointer to the AVOption corresponding to the field set or
|
||||
* NULL if no matching AVOption exists, or if the value val is not
|
||||
* valid
|
||||
* @see av_set_string3()
|
||||
*/
|
||||
attribute_deprecated const AVOption *av_set_string2(void *obj, const char *name, const char *val, int alloc);
|
||||
#endif
|
||||
#if FF_API_OPT_SHOW
|
||||
/**
|
||||
* @deprecated Use av_opt_show2() instead.
|
||||
*/
|
||||
attribute_deprecated int av_opt_show(void *obj, void *av_log_obj);
|
||||
#endif
|
||||
|
||||
#endif /* AVCODEC_OPT_H */
|
||||
|
@@ -438,6 +438,7 @@ static const AVOption options[]={
|
||||
{"crf_max", "in crf mode, prevents vbv from lowering quality beyond this point", OFFSET(crf_max), FF_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, 0, 51, V|E},
|
||||
{"log_level_offset", "set the log level offset", OFFSET(log_level_offset), FF_OPT_TYPE_INT, {.dbl = 0 }, INT_MIN, INT_MAX },
|
||||
#if FF_API_FLAC_GLOBAL_OPTS
|
||||
{"use_lpc", "sets whether to use LPC mode (FLAC)", OFFSET(use_lpc), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E},
|
||||
{"lpc_type", "deprecated, use flac-specific options", OFFSET(lpc_type), FF_OPT_TYPE_INT, {.dbl = AV_LPC_TYPE_DEFAULT }, AV_LPC_TYPE_DEFAULT, AV_LPC_TYPE_NB-1, A|E},
|
||||
{"none", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = AV_LPC_TYPE_NONE }, INT_MIN, INT_MAX, A|E, "lpc_type"},
|
||||
{"fixed", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = AV_LPC_TYPE_FIXED }, INT_MIN, INT_MAX, A|E, "lpc_type"},
|
||||
|
@@ -105,6 +105,43 @@ void ff_fetch_timestamp(AVCodecParserContext *s, int off, int remove){
|
||||
}
|
||||
}
|
||||
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 53
|
||||
/**
|
||||
*
|
||||
* @param buf input
|
||||
* @param buf_size input length, to signal EOF, this should be 0 (so that the last frame can be output)
|
||||
* @param pts input presentation timestamp
|
||||
* @param dts input decoding timestamp
|
||||
* @param poutbuf will contain a pointer to the first byte of the output frame
|
||||
* @param poutbuf_size will contain the length of the output frame
|
||||
* @return the number of bytes of the input bitstream used
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* while(in_len){
|
||||
* len = av_parser_parse(myparser, AVCodecContext, &data, &size,
|
||||
* in_data, in_len,
|
||||
* pts, dts);
|
||||
* in_data += len;
|
||||
* in_len -= len;
|
||||
*
|
||||
* if(size)
|
||||
* decode_frame(data, size);
|
||||
* }
|
||||
* @endcode
|
||||
*
|
||||
* @deprecated Use av_parser_parse2() instead.
|
||||
*/
|
||||
int av_parser_parse(AVCodecParserContext *s,
|
||||
AVCodecContext *avctx,
|
||||
uint8_t **poutbuf, int *poutbuf_size,
|
||||
const uint8_t *buf, int buf_size,
|
||||
int64_t pts, int64_t dts)
|
||||
{
|
||||
return av_parser_parse2(s, avctx, poutbuf, poutbuf_size, buf, buf_size, pts, dts, AV_NOPTS_VALUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
int av_parser_parse2(AVCodecParserContext *s,
|
||||
AVCodecContext *avctx,
|
||||
uint8_t **poutbuf, int *poutbuf_size,
|
||||
|
@@ -469,12 +469,10 @@ static int decode_frame(AVCodecContext *avctx,
|
||||
avctx->pix_fmt = PIX_FMT_RGB48BE;
|
||||
} else if (s->bit_depth == 1) {
|
||||
avctx->pix_fmt = PIX_FMT_MONOBLACK;
|
||||
} else if (s->bit_depth == 8 &&
|
||||
s->color_type == PNG_COLOR_TYPE_PALETTE) {
|
||||
} else if (s->color_type == PNG_COLOR_TYPE_PALETTE) {
|
||||
avctx->pix_fmt = PIX_FMT_PAL8;
|
||||
} else if (s->bit_depth == 8 &&
|
||||
s->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
|
||||
avctx->pix_fmt = PIX_FMT_Y400A;
|
||||
} else if (s->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
|
||||
avctx->pix_fmt = PIX_FMT_GRAY8A;
|
||||
} else {
|
||||
goto fail;
|
||||
}
|
||||
|
@@ -55,7 +55,7 @@ static void png_get_interlaced_row(uint8_t *dst, int row_size,
|
||||
uint8_t *d;
|
||||
const uint8_t *s;
|
||||
|
||||
mask = (int[]){0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}[pass];
|
||||
mask = ff_png_pass_mask[pass];
|
||||
switch(bits_per_pixel) {
|
||||
case 1:
|
||||
memset(dst, 0, row_size);
|
||||
|
@@ -332,9 +332,6 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src,
|
||||
dst->height = src->height;
|
||||
dst->pix_fmt = src->pix_fmt;
|
||||
|
||||
dst->coded_width = src->coded_width;
|
||||
dst->coded_height = src->coded_height;
|
||||
|
||||
dst->has_b_frames = src->has_b_frames;
|
||||
dst->idct_algo = src->idct_algo;
|
||||
dst->slice_count = src->slice_count;
|
||||
@@ -383,6 +380,9 @@ static void update_context_from_user(AVCodecContext *dst, AVCodecContext *src)
|
||||
dst->release_buffer = src->release_buffer;
|
||||
|
||||
dst->opaque = src->opaque;
|
||||
#if FF_API_HURRY_UP
|
||||
dst->hurry_up = src->hurry_up;
|
||||
#endif
|
||||
dst->dsp_mask = src->dsp_mask;
|
||||
dst->debug = src->debug;
|
||||
dst->debug_mv = src->debug_mv;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user