Compare commits

...

15 Commits

Author SHA1 Message Date
Timothy Gu
327033d913 jni: Return ENOSYS on unsupported platforms 2016-08-02 22:33:03 -07:00
Carl Eugen Hoyos
9a345b235f lavu/hwcontext_vaapi: Fix compilation if VA_FOURCC_ABGR is not defined.
Fixes ticket #5484.
(cherry picked from commit 5aede05120)
2016-08-02 23:25:07 +02:00
Michael Niedermayer
8f6a95a103 avcodec/vp9_parser: Check the input frame sizes for being consistent
Suggested-by: BBB
Fixed-by: BBB
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 77b0f3f26d)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-08-01 17:29:14 +02:00
Xinzheng Zhang
b4922daead avformat/flvdec: parse keyframe before a\v stream was created add_keyframes_index() when stream created or keyframe parsed
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ad14aab3b4)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-08-01 17:29:14 +02:00
Xinzheng Zhang
88e3e6b943 avformat/flvdec: splitting add_keyframes_index() out from parse_keyframes_index()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit cd141e71bd)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-08-01 17:29:14 +02:00
Kacper Michajłow
87d5146fb7 libavformat/rtpdec_asf: zero initialize the AVIOContext struct
This fixes crash in avformat_open_input() when accessing
protocol_whitelist field.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e947b75b1c)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-08-01 17:29:14 +02:00
Kacper Michajłow
caf32880fd libavutil/opt: Small bugfix in example.
Fix const corectness and zero init the struct. This example code would actually crash when initializing string.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 69630f4d30)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-08-01 17:29:14 +02:00
Sasi Inguva
7c01fa962e libx264: Increase x264 opts character limit to 4096
Signed-off-by: Sasi Inguva <isasi@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 282477bf45)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-08-01 17:29:14 +02:00
Michael Niedermayer
e4eab67a0a avcodec/h264_parser: Set sps/pps_ref
Fixes use of freed memory
Should fix valgrind failures of fate-h264-skip-nointra

Found-by: logan
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit febc862b53)

Conflicts:

	libavcodec/h264_parser.c
2016-08-01 17:29:14 +02:00
Luca Barbato
86f9228740 librtmp: Avoid an infiniloop setting connection arguments
The exit condition was missing.

Signed-off-by: Timothy Gu <timothygu99@gmail.com>
(cherry picked from commit e85d38c20a)
Signed-off-by: Timothy Gu <timothygu99@gmail.com>
2016-07-26 12:07:40 -07:00
James Almer
7cab4142c5 avformat/oggparsevp8: fix pts calculation on pages ending with an invisible frame
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 5adfbd3918)
2016-07-25 10:01:11 -03:00
Carl Eugen Hoyos
2e1be22715 lavc/Makefile: Fix standalone compilation of the svq3 decoder.
Regression since 0bf5fd2e
(cherry picked from commit 71167f7f84)
2016-07-24 23:56:39 +02:00
Clément Bœsch
7da59005be lavf/vplayerdec: Improve auto-detection.
Fixes the incorrect detection of 16_selma_OneFrame_QP39.yuv (gray16le
rawvideo) as vplayer format.
(cherry picked from commit 77726d32a8)
2016-07-15 10:36:59 +02:00
Matthieu Bouron
1410732621 lavc/mediacodecdec_h264: properly convert extradata to annex-b
H264ParamSets has its SPS/PPS stored raw (SODB) and needs to be
converted to NAL units before sending them to MediaCodec.

This patch adds the missing convertion of the SPS/PPS from SOBP to RBSP
which makes the resulting NAL units correct.

Fixes codec initialization on Nexus 4 and Nexus 7.

(cherry picked from commit 88d9c30cf5)
2016-07-11 15:32:30 +02:00
James Almer
f9a150fc31 Revert "configure: Enable GCC vectorization on ≥4.9 on x86"
This reverts commit cb8646af24.

This change has brough more issues than benefits, between compilation
time failures depending on flags used and code miscompilation causing
runtime crashes.

See the "[PATCH 2/2] configure: Enable GCC vectorization on ≥4.9"
thread in the ffmpeg-devel mailing list for the relevant discussion.

(cherry picked from commit fd6dbc5385)
2016-07-09 17:38:48 -03:00
14 changed files with 180 additions and 51 deletions

6
configure vendored
View File

@@ -6125,11 +6125,7 @@ elif enabled ccc; then
add_cflags -msg_disable nonstandcast
add_cflags -msg_disable unsupieee
elif enabled gcc; then
case $gcc_basever in
4.9*) enabled x86 || check_optflags -fno-tree-vectorize ;;
4.*) check_optflags -fno-tree-vectorize ;;
*) enabled x86 || check_optflags -fno-tree-vectorize ;;
esac
check_optflags -fno-tree-vectorize
check_cflags -Werror=format-security
check_cflags -Werror=implicit-function-declaration
check_cflags -Werror=missing-prototypes

View File

@@ -528,7 +528,8 @@ OBJS-$(CONFIG_SUNRAST_ENCODER) += sunrastenc.o
OBJS-$(CONFIG_SVQ1_DECODER) += svq1dec.o svq1.o svq13.o h263data.o
OBJS-$(CONFIG_SVQ1_ENCODER) += svq1enc.o svq1.o h263data.o \
h263.o ituh263enc.o
OBJS-$(CONFIG_SVQ3_DECODER) += svq3.o svq13.o mpegutils.o h264_parse.o h264data.o
OBJS-$(CONFIG_SVQ3_DECODER) += svq3.o svq13.o mpegutils.o \
h264_parse.o h264data.o h264_ps.o h2645_parse.o
OBJS-$(CONFIG_TEXT_DECODER) += textdec.o ass.o
OBJS-$(CONFIG_TEXT_ENCODER) += srtenc.o ass_split.o
OBJS-$(CONFIG_TAK_DECODER) += takdec.o tak.o takdsp.o

View File

@@ -367,13 +367,26 @@ static inline int parse_nal_units(AVCodecParserContext *s,
"non-existing PPS %u referenced\n", pps_id);
goto fail;
}
p->ps.pps = (const PPS*)p->ps.pps_list[pps_id]->data;
av_buffer_unref(&p->ps.pps_ref);
av_buffer_unref(&p->ps.sps_ref);
p->ps.pps = NULL;
p->ps.sps = NULL;
p->ps.pps_ref = av_buffer_ref(p->ps.pps_list[pps_id]);
if (!p->ps.pps_ref)
goto fail;
p->ps.pps = (const PPS*)p->ps.pps_ref->data;
if (!p->ps.sps_list[p->ps.pps->sps_id]) {
av_log(avctx, AV_LOG_ERROR,
"non-existing SPS %u referenced\n", p->ps.pps->sps_id);
goto fail;
}
p->ps.sps = (SPS*)p->ps.sps_list[p->ps.pps->sps_id]->data;
p->ps.sps_ref = av_buffer_ref(p->ps.sps_list[p->ps.pps->sps_id]);
if (!p->ps.sps_ref)
goto fail;
p->ps.sps = (SPS*)p->ps.sps_ref->data;
sps = p->ps.sps;

View File

@@ -20,19 +20,18 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
#include <stdlib.h>
#include "config.h"
#include "libavutil/error.h"
#include "jni.h"
#if CONFIG_JNI
#include <errno.h>
#include <jni.h>
#include <pthread.h>
#include "libavutil/log.h"
#include "libavutil/error.h"
#include "ffjni.h"
void *java_vm;
@@ -69,7 +68,7 @@ void *av_jni_get_java_vm(void *log_ctx)
int av_jni_set_java_vm(void *vm, void *log_ctx)
{
return 0;
return AVERROR(ENOSYS);
}
void *av_jni_get_java_vm(void *log_ctx)

View File

@@ -777,8 +777,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
if(x4->x264opts){
const char *p= x4->x264opts;
while(p){
char param[256]={0}, val[256]={0};
if(sscanf(p, "%255[^:=]=%255[^:]", param, val) == 1){
char param[4096]={0}, val[4096]={0};
if(sscanf(p, "%4095[^:=]=%4095[^:]", param, val) == 1){
OPT_STR(param, "1");
}else
OPT_STR(param, val);

View File

@@ -65,6 +65,58 @@ static av_cold int mediacodec_decode_close(AVCodecContext *avctx)
return 0;
}
static int h264_ps_to_nalu(const uint8_t *src, int src_size, uint8_t **out, int *out_size)
{
int i;
int ret = 0;
uint8_t *p = NULL;
static const uint8_t nalu_header[] = { 0x00, 0x00, 0x00, 0x01 };
if (!out || !out_size) {
return AVERROR(EINVAL);
}
p = av_malloc(sizeof(nalu_header) + src_size);
if (!p) {
return AVERROR(ENOMEM);
}
*out = p;
*out_size = sizeof(nalu_header) + src_size;
memcpy(p, nalu_header, sizeof(nalu_header));
memcpy(p + sizeof(nalu_header), src, src_size);
/* Escape 0x00, 0x00, 0x0{0-3} pattern */
for (i = 4; i < *out_size; i++) {
if (i < *out_size - 3 &&
p[i + 0] == 0 &&
p[i + 1] == 0 &&
p[i + 2] <= 3) {
uint8_t *new;
*out_size += 1;
new = av_realloc(*out, *out_size);
if (!new) {
ret = AVERROR(ENOMEM);
goto done;
}
*out = p = new;
i = i + 3;
memmove(p + i, p + i - 1, *out_size - i);
p[i - 1] = 0x03;
}
}
done:
if (ret < 0) {
av_freep(out);
*out_size = 0;
}
return ret;
}
static av_cold int mediacodec_decode_init(AVCodecContext *avctx)
{
int i;
@@ -112,24 +164,19 @@ static av_cold int mediacodec_decode_init(AVCodecContext *avctx)
}
if (pps && sps) {
static const uint8_t nal_headers[] = { 0x00, 0x00, 0x00, 0x01 };
uint8_t *data = NULL;
size_t data_size = sizeof(nal_headers) + FFMAX(sps->data_size, pps->data_size);
size_t data_size = 0;
data = av_mallocz(data_size);
if (!data) {
ret = AVERROR(ENOMEM);
if ((ret = h264_ps_to_nalu(sps->data, sps->data_size, &data, &data_size)) < 0) {
goto done;
}
ff_AMediaFormat_setBuffer(format, "csd-0", (void*)data, data_size);
av_freep(&data);
memcpy(data, nal_headers, sizeof(nal_headers));
memcpy(data + sizeof(nal_headers), sps->data, sps->data_size);
ff_AMediaFormat_setBuffer(format, "csd-0", (void*)data, sizeof(nal_headers) + sps->data_size);
memcpy(data + sizeof(nal_headers), pps->data, pps->data_size);
ff_AMediaFormat_setBuffer(format, "csd-1", (void*)data, sizeof(nal_headers) + pps->data_size);
if ((ret = h264_ps_to_nalu(pps->data, pps->data_size, &data, &data_size)) < 0) {
goto done;
}
ff_AMediaFormat_setBuffer(format, "csd-1", (void*)data, data_size);
av_freep(&data);
} else {
av_log(avctx, AV_LOG_ERROR, "Could not extract PPS/SPS from extradata");

View File

@@ -28,6 +28,7 @@
typedef struct VP9ParseContext {
int n_frames; // 1-8
int size[8];
int marker_size;
int64_t pts;
} VP9ParseContext;
@@ -88,6 +89,21 @@ static int parse(AVCodecParserContext *ctx,
return 0;
}
if (s->n_frames > 0) {
int i;
int size_sum = 0;
for (i = 0; i < s->n_frames ;i++)
size_sum += s->size[i];
size_sum += s->marker_size;
if (size_sum != size) {
av_log(avctx, AV_LOG_ERROR, "Inconsistent input frame sizes %d %d\n",
size_sum, size);
s->n_frames = 0;
}
}
if (s->n_frames > 0) {
*out_data = data;
*out_size = s->size[--s->n_frames];
@@ -131,6 +147,7 @@ static int parse(AVCodecParserContext *ctx,
data += sz; \
size -= sz; \
} \
s->marker_size = size; \
parse_frame(ctx, *out_data, *out_size); \
return s->n_frames > 0 ? *out_size : full_size

View File

@@ -61,6 +61,11 @@ typedef struct FLVContext {
int broken_sizes;
int sum_flv_tag_size;
int last_keyframe_stream_index;
int keyframe_count;
int64_t *keyframe_times;
int64_t *keyframe_filepositions;
} FLVContext;
static int probe(AVProbeData *p, int live)
@@ -92,8 +97,38 @@ static int live_flv_probe(AVProbeData *p)
return probe(p, 1);
}
static void add_keyframes_index(AVFormatContext *s)
{
FLVContext *flv = s->priv_data;
AVStream *stream = NULL;
unsigned int i = 0;
if (flv->last_keyframe_stream_index < 0) {
av_log(s, AV_LOG_DEBUG, "keyframe stream hasn't been created\n");
return;
}
av_assert0(flv->last_keyframe_stream_index <= s->nb_streams);
stream = s->streams[flv->last_keyframe_stream_index];
if (stream->nb_index_entries == 0) {
for (i = 0; i < flv->keyframe_count; i++) {
av_add_index_entry(stream, flv->keyframe_filepositions[i],
flv->keyframe_times[i] * 1000, 0, 0, AVINDEX_KEYFRAME);
}
} else
av_log(s, AV_LOG_WARNING, "Skipping duplicate index\n");
if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
av_freep(&flv->keyframe_times);
av_freep(&flv->keyframe_filepositions);
flv->keyframe_count = 0;
}
}
static AVStream *create_stream(AVFormatContext *s, int codec_type)
{
FLVContext *flv = s->priv_data;
AVStream *st = avformat_new_stream(s, NULL);
if (!st)
return NULL;
@@ -104,6 +139,8 @@ static AVStream *create_stream(AVFormatContext *s, int codec_type)
s->ctx_flags &= ~AVFMTCTX_NOHEADER;
avpriv_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */
flv->last_keyframe_stream_index = s->nb_streams - 1;
add_keyframes_index(s);
return st;
}
@@ -305,8 +342,7 @@ static int amf_get_string(AVIOContext *ioc, char *buffer, int buffsize)
return length;
}
static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc,
AVStream *vstream, int64_t max_pos)
static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, int64_t max_pos)
{
FLVContext *flv = s->priv_data;
unsigned int timeslen = 0, fileposlen = 0, i;
@@ -316,10 +352,12 @@ static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc,
int ret = AVERROR(ENOSYS);
int64_t initial_pos = avio_tell(ioc);
if (vstream->nb_index_entries>0) {
av_log(s, AV_LOG_WARNING, "Skipping duplicate index\n");
if (flv->keyframe_count > 0) {
av_log(s, AV_LOG_DEBUG, "keyframes have been paresed\n");
return 0;
}
av_assert0(!flv->keyframe_times);
av_assert0(!flv->keyframe_filepositions);
if (s->flags & AVFMT_FLAG_IGNIDX)
return 0;
@@ -368,15 +406,16 @@ static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc,
}
if (timeslen == fileposlen && fileposlen>1 && max_pos <= filepositions[0]) {
for (i = 0; i < fileposlen; i++) {
av_add_index_entry(vstream, filepositions[i], times[i] * 1000,
0, 0, AVINDEX_KEYFRAME);
if (i < 2) {
flv->validate_index[i].pos = filepositions[i];
flv->validate_index[i].dts = times[i] * 1000;
flv->validate_count = i + 1;
}
for (i = 0; i < FFMIN(2,fileposlen); i++) {
flv->validate_index[i].pos = filepositions[i];
flv->validate_index[i].dts = times[i] * 1000;
flv->validate_count = i + 1;
}
flv->keyframe_times = times;
flv->keyframe_filepositions = filepositions;
flv->keyframe_count = timeslen;
times = NULL;
filepositions = NULL;
} else {
invalid:
av_log(s, AV_LOG_WARNING, "Invalid keyframes object, skipping.\n");
@@ -418,13 +457,14 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream,
}
break;
case AMF_DATA_TYPE_OBJECT:
if ((vstream || astream) && key &&
if (key &&
ioc->seekable &&
!strcmp(KEYFRAMES_TAG, key) && depth == 1)
if (parse_keyframes_index(s, ioc, vstream ? vstream : astream,
if (parse_keyframes_index(s, ioc,
max_pos) < 0)
av_log(s, AV_LOG_ERROR, "Keyframe index parsing failed\n");
else
add_keyframes_index(s);
while (avio_tell(ioc) < max_pos - 2 &&
amf_get_string(ioc, str_val, sizeof(str_val)) > 0)
if (amf_parse_object(s, astream, vstream, str_val, max_pos,
@@ -574,6 +614,7 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream,
static int flv_read_metabody(AVFormatContext *s, int64_t next_pos)
{
FLVContext *flv = s->priv_data;
AMFDataType type;
AVStream *stream, *astream, *vstream;
AVStream av_unused *dstream;
@@ -612,10 +653,14 @@ static int flv_read_metabody(AVFormatContext *s, int64_t next_pos)
// the lookup every time it is called.
for (i = 0; i < s->nb_streams; i++) {
stream = s->streams[i];
if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
vstream = stream;
else if (stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
flv->last_keyframe_stream_index = i;
} else if (stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
astream = stream;
if (flv->last_keyframe_stream_index == -1)
flv->last_keyframe_stream_index = i;
}
else if (stream->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE)
dstream = stream;
}
@@ -643,6 +688,7 @@ static int flv_read_header(AVFormatContext *s)
s->start_time = 0;
flv->sum_flv_tag_size = 0;
flv->last_keyframe_stream_index = -1;
return 0;
}
@@ -653,6 +699,8 @@ static int flv_read_close(AVFormatContext *s)
FLVContext *flv = s->priv_data;
for (i=0; i<FLV_STREAM_TYPE_NB; i++)
av_freep(&flv->new_extradata[i]);
av_freep(&flv->keyframe_times);
av_freep(&flv->keyframe_filepositions);
return 0;
}

View File

@@ -193,6 +193,8 @@ static int rtmp_open(URLContext *s, const char *uri, int flags)
if (sep)
p = sep + 1;
else
break;
}
}
if (ctx->playpath) {

View File

@@ -82,7 +82,11 @@ static uint64_t vp8_gptopts(AVFormatContext *s, int idx,
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx;
uint64_t pts = (granule >> 32);
int invcnt = !((granule >> 30) & 3);
// If page granule is that of an invisible vp8 frame, its pts will be
// that of the end of the next visible frame. We substract 1 for those
// to prevent messing up pts calculations.
uint64_t pts = (granule >> 32) - invcnt;
uint32_t dist = (granule >> 3) & 0x07ffffff;
if (!dist)

View File

@@ -101,7 +101,7 @@ int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p)
{
int ret = 0;
if (av_strstart(p, "pgmpu:data:application/vnd.ms.wms-hdr.asfv1;base64,", &p)) {
AVIOContext pb;
AVIOContext pb = { 0 };
RTSPState *rt = s->priv_data;
AVDictionary *opts = NULL;
int len = strlen(p) * 6 / 8;

View File

@@ -36,8 +36,8 @@ static int vplayer_probe(AVProbeData *p)
char c;
const unsigned char *ptr = p->buf;
if ((sscanf(ptr, "%*d:%*d:%*d.%*d%c", &c) == 1 ||
sscanf(ptr, "%*d:%*d:%*d%c", &c) == 1) && strchr(": =", c))
if ((sscanf(ptr, "%*3d:%*2d:%*2d.%*2d%c", &c) == 1 ||
sscanf(ptr, "%*3d:%*2d:%*2d%c", &c) == 1) && strchr(": =", c))
return AVPROBE_SCORE_MAX;
return 0;
}

View File

@@ -115,8 +115,10 @@ static struct {
MAP(BGRX, RGB32, BGR0),
MAP(RGBA, RGB32, RGBA),
MAP(RGBX, RGB32, RGB0),
#ifdef VA_FOURCC_ABGR
MAP(ABGR, RGB32, ABGR),
MAP(XBGR, RGB32, 0BGR),
#endif
MAP(ARGB, RGB32, ARGB),
MAP(XRGB, RGB32, 0RGB),
};

View File

@@ -58,7 +58,7 @@
* The following example illustrates an AVOptions-enabled struct:
* @code
* typedef struct test_struct {
* AVClass *class;
* const AVClass *class;
* int int_opt;
* char *str_opt;
* uint8_t *bin_opt;
@@ -96,7 +96,7 @@
* @code
* test_struct *alloc_test_struct(void)
* {
* test_struct *ret = av_malloc(sizeof(*ret));
* test_struct *ret = av_mallocz(sizeof(*ret));
* ret->class = &test_class;
* av_opt_set_defaults(ret);
* return ret;