Commit Graph

156 Commits

Author SHA1 Message Date
Michael Niedermayer 9859f54db3 avformat/ffmdec: Silence "may be used uninitialized in this function" warnings
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-12-03 19:45:31 +01:00
Michael Niedermayer b98510de5c avformat/ffmdec: cleanup on extradata memory allocation failure
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-12-03 19:45:31 +01:00
Michael Niedermayer fdf588d7cf avformat/ffmdec: Forward error code from ffm_read_header()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-12-03 19:45:31 +01:00
Michael Niedermayer c143e7939f avformat/ffmdec: remove last use of st->codec
Reviewed-by: Andreas Cadhalpun <andreas.cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-12-03 17:25:40 +01:00
Michael Niedermayer 418a2b2478 avformat/ffmdec: Drop flags2, debug and codec->time_base setting
It should still be possible to set these through recommended_encoder_configuration

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-12-03 14:05:15 +01:00
Michael Niedermayer e706e2e775 avformat/ffmdec: Check media type for chunks
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-12-03 14:05:15 +01:00
Michael Niedermayer 591c032421 avformat/ffmdec: replace most codec uses by codecpar
This is a bit messy as codecar does not support AVOptions so we need
to use AVCodecContext where AVOptions are required and copy back and forth.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-12-03 14:05:15 +01:00
Michael Niedermayer 5cd3ea1cc0 avformat/ffmdec: Remove some st->codec uses which set encoder parameters
Modern ffserver should not need these

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-12-03 14:05:15 +01:00
Andreas Cadhalpun 1c7da19a4b ffmdec: validate codec parameters
A negative extradata size for example gets passed to memcpy in
avcodec_parameters_from_context causing a segmentation fault.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2016-11-20 20:08:35 +01:00
Andreas Cadhalpun 0009457dc0 ffmdec: validate sample_rate
A negative sample rate doesn't make sense and triggers assertions in
av_rescale_rnd.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2016-11-07 00:51:49 +01:00
Michael Niedermayer 78baa450d9 avformat/ffmdec: Check pix_fmt
Fixes crash
Fixes Ticket5412

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-04-28 23:25:18 +02:00
Derek Buitenhuis 6f69f7a8bf Merge commit '9200514ad8717c63f82101dc394f4378854325bf'
* commit '9200514ad8717c63f82101dc394f4378854325bf':
  lavf: replace AVStream.codec with AVStream.codecpar

This has been a HUGE effort from:
    - Derek Buitenhuis <derek.buitenhuis@gmail.com>
    - Hendrik Leppkes <h.leppkes@gmail.com>
    - wm4 <nfxjfg@googlemail.com>
    - Clément Bœsch <clement@stupeflix.com>
    - James Almer <jamrial@gmail.com>
    - Michael Niedermayer <michael@niedermayer.cc>
    - Rostislav Pehlivanov <atomnuker@gmail.com>

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-04-10 20:59:55 +01:00
Oliver Collyer a2f8beef2d ffserver&ffm: Fixed issues preventing ffserver write_index and files_size from being set correctly which was breaking ffserver streaming.
I discovered that ffserver streaming was broken (it seems like it has been since 20th November) and I opened a ticket for this (https://trac.ffmpeg.org/ticket/5250 <https://trac.ffmpeg.org/ticket/5250>).

I spent yesterday learning git bisect (with the kind help of cehoyos) to painstakingly track down the cause. This was made more difficult due to the presence of a segfault in ffserver during the period where the bug was introduced so I first had to identify when and how that was fixed and then retrospectively apply that fix again for each step of the second git bisect to find the actual bug.

Anyway, the fruits of my labour are the innocent looking patch below to correct a couple of typos and define a valid range for two variables.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-21 12:59:07 +01:00
Andreas Cadhalpun f6e1c96730 ffmdec: change type of len to ptrdiff_t
It is used to store the difference between pointers, so ptrdiff_t is the
correct type.

This prevents potential overflows.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2016-01-11 23:14:52 +01:00
Andreas Cadhalpun 40eb2531b2 ffmdec: reset packet_end in case of failure
This fixes segmentation faults caused by passing a packet_ptr of NULL to
memcpy.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2016-01-03 21:13:01 +01:00
Michael Niedermayer 97c162add7 avformat/ffmdec: Add {} to nested if/else
This preempts potential bugs if this is changed and the indention
ends up different from C interpretation

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-01-03 16:08:32 +01:00
Andreas Cadhalpun 2e752c7de9 ffmdec: change type of state and id to unsigned
This fixes ubsan runtime error: left shift by 8 places cannot be
represented in type 'int'

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2016-01-02 20:03:57 +01:00
Andreas Cadhalpun ecf63b7cc2 ffm: reject invalid codec_id and codec_type
A negative codec_id cannot be handled by the found_decoder API of
AVStream->info: if the codec_id is not recognized, found_decoder is set
to -codec_id, which has to be '<0' according to the API documentation.

This can cause NULL pointer dereferencing in try_decode_frame.

Also make sure the codec_type matches the expected one for codec_id.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-12-15 22:43:25 +01:00
Andreas Cadhalpun a611375db5 ffmdec: reject zero-sized chunks
If size is zero, avio_get_str fails, leaving the buffer uninitialized.
This causes invalid reads in av_set_options_string.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-12-04 15:20:04 +01:00
Andreas Cadhalpun 488e9a06f0 ffmdec: only seek back at EOF if a server is attached
Otherwise the ffm demuxer can return the same packets endlessly, if
there is no server attached.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-12-04 15:20:04 +01:00
Michael Niedermayer 9b7d39de81 avformat/ffmdec: Only return EAGAIN if a server is attached
This should fix a infinite loop

Reviewed-by: Andreas Cadhalpun <andreas.cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-20 20:08:26 +01:00
Michael Niedermayer 3444c00aab avformat/ffmdec: Add cleaner API for ffserver to interface without depending on internal ABI
Reviewed-by: Andreas Cadhalpun <andreas.cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-20 20:01:05 +01:00
Hendrik Leppkes c2f861ca42 Replace remaining occurances of av_free_packet with av_packet_unref 2015-10-27 14:35:30 +01:00
Andreas Cadhalpun 8d6625642d doc: fix spelling errors
Reviewed-by: Lou Logan <lou@lrcd.com>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-10-09 22:09:08 +02:00
Ronald S. Bultje 229843aa35 Replace av_dlog with ff_dlog.
ff_dlog checks compilability, and is non-public. av_dlog is deprecated
and no longer exists if FF_API_DLOG=0.
2015-08-18 10:24:01 -04:00
Michael Niedermayer 94d68a41fa Merge commit '7c6eb0a1b7bf1aac7f033a7ec6d8cacc3b5c2615'
* commit '7c6eb0a1b7bf1aac7f033a7ec6d8cacc3b5c2615':
  lavc: AV-prefix all codec flags

Conflicts:
	doc/examples/muxing.c
	ffmpeg.c
	ffmpeg_opt.c
	ffplay.c
	libavcodec/aacdec.c
	libavcodec/aacenc.c
	libavcodec/ac3dec.c
	libavcodec/ac3enc_float.c
	libavcodec/atrac1.c
	libavcodec/atrac3.c
	libavcodec/atrac3plusdec.c
	libavcodec/dcadec.c
	libavcodec/ffv1enc.c
	libavcodec/h264.c
	libavcodec/h264_loopfilter.c
	libavcodec/h264_mb.c
	libavcodec/imc.c
	libavcodec/libmp3lame.c
	libavcodec/libtheoraenc.c
	libavcodec/libtwolame.c
	libavcodec/libvpxenc.c
	libavcodec/libxavs.c
	libavcodec/libxvid.c
	libavcodec/mpeg12dec.c
	libavcodec/mpeg12enc.c
	libavcodec/mpegaudiodec_template.c
	libavcodec/mpegvideo.c
	libavcodec/mpegvideo_enc.c
	libavcodec/mpegvideo_motion.c
	libavcodec/nellymoserdec.c
	libavcodec/nellymoserenc.c
	libavcodec/nvenc.c
	libavcodec/on2avc.c
	libavcodec/options_table.h
	libavcodec/opus_celt.c
	libavcodec/pngenc.c
	libavcodec/ra288.c
	libavcodec/ratecontrol.c
	libavcodec/twinvq.c
	libavcodec/vc1_block.c
	libavcodec/vc1_loopfilter.c
	libavcodec/vc1_mc.c
	libavcodec/vc1dec.c
	libavcodec/vorbisdec.c
	libavcodec/vp3.c
	libavcodec/wma.c
	libavcodec/wmaprodec.c
	libavcodec/x86/hpeldsp_init.c
	libavcodec/x86/me_cmp_init.c

Merged-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-27 22:10:35 +02:00
Michael Niedermayer dc55477a64 avformat/ffmdec: Check ffio_set_buf_size() return value
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-07 14:55:10 +02:00
Himangi Saraogi 8d15de7eb2 ffmdec: Check return value of ffm_append_recommended_configuration
Reviewed-by: Lukasz Marek <lukasz.m.luki2@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-10 14:44:53 +02:00
Andreas Cadhalpun 6b8263b03a ffmdec: limit the backward seek to the last resync position
If resyncing leads to the same position as previously, it will again
lead to a resync attempt, resulting in an infinite loop.

Thus don't seek back beyond the last syncpoint.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-09 15:19:34 +01:00
Andreas Cadhalpun 4c91d81be2 ffmdec: make sure the time base is valid
A negative time base can trigger assertions.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-09 13:40:20 +01:00
Andreas Cadhalpun 6fa98822eb ffmdec: fix infinite loop at EOF
If EOF is reached, while skipping bytes, avio_tell(pb) won't change
anymore, resulting in an infinite loop.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-09 03:14:16 +01:00
Andreas Cadhalpun 66879ee125 ffmdec: initialize f_cprv, f_stvi and f_stau
They are used in a switch statement, but it is not guaranteed that the
COMM case (where they are set to 0) is reached before the other cases.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-09 02:19:03 +01:00
Lukasz Marek 568853b8f5 lavf/ffmdec: add common options to recommended encoder configuration
Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com>
2014-11-27 23:19:20 +01:00
Lukasz Marek ec01283752 lavf/ffmdec: reident after last commit
Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com>
2014-11-16 01:57:26 +01:00
Lukasz Marek 745730c9c2 lavf/ffm: use AVOption API to store/restore stream properties
This is a generic solution that will not reqiore modifications when new options are added.
This also fixes problem with current implementation when qmin or qmax=-1.
Only 8 bits was sent and read back as 255.

Fixes #1275
Fixes #1461

Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com>
2014-11-16 01:13:38 +01:00
Lukasz Marek 6690d4c3f5 lavf/ffm: store/restore private codec context
Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com>
2014-11-16 01:13:38 +01:00
Stefano Sabatini 6f0fc1a96b lavf/ffmdec: return proper error code in ffm2_read_header()
Also log an error message in case of invalid packet size.
2014-09-05 11:20:07 +02:00
James Almer d34ec64a22 replace calls to url_feof() with avio_feof()
Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-08 00:48:38 +02:00
Anton Khirnov 894682a973 Remove avserver.
It has not been properly maintained for years and there is little hope
of that changing in the future.
It appears simpler to write a new replacement from scratch than
unbreaking it.
2014-06-18 14:55:28 +02:00
Lou Logan 88f2586adb fix various typos
Signed-off-by: Lou Logan <lou@lrcd.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-03 10:58:19 -08:00
Michael Niedermayer c633aeba45 avformat/ffmdec: use ff_get_extradata()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-12-25 17:23:55 +01:00
Michael Niedermayer ccdfa3e271 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  Add missing #includes for *INT64_MAX and *INT64_C

Conflicts:
	ffmpeg.c
	ffmpeg_filter.c
	ffplay.c
	libavformat/assdec.c
	libavformat/avidec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-11-24 05:21:19 +01:00
Diego Biurrun 8f8bc92365 Add missing #includes for *INT64_MAX and *INT64_C 2013-11-23 21:55:52 +01:00
Paul B Mahol a807c68253 avformat: use ff_alloc_extradata()
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-10-13 20:13:38 +00:00
Michael Niedermayer 60e028958c ffmdec: remove unused variable
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-11-08 15:54:14 +01:00
Michael Niedermayer 9829ec1a9c ffm: redesign header format to make it extensible
Currently FFM files generated with one versions of ffmpeg generally
cannot be read by another.
By spliting data into chunks, more fields can saftely be appended to
chunks as well as new chunks added.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-11-05 16:36:44 +01:00
Michael Niedermayer f03c0f6afc ffmdec: check av_new_packet() return value
Fixes CID733711
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-10-17 20:45:59 +02:00
Michael Niedermayer a0e0e1e192 ffmdec: fix hypothetical overflows
Fixes CID703739
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-10-17 20:36:30 +02:00
Michael Niedermayer 7fd65104f4 ffm_seek: fix division by zero
Fixes CID732202
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-10-17 20:14:43 +02:00
Michael Niedermayer d6e87190fd Merge commit 'a25d912dca9cd553440167e0476c47581359c0fc'
* commit 'a25d912dca9cd553440167e0476c47581359c0fc':
  avcodec_encode_audio(): fix invalid free
  pcm-mpeg: correct bitrate calculation
  ffv1: K&R formatting cosmetics
  fate: Add rangecoder test
  network: #include stdint.h in network.h
  nut: export codec_tag provided by rawvideo
  avserver: move avserver-specific code from ffmdec.c to avserver.c

Conflicts:
	ffserver.c
	libavcodec/ffv1.c
	libavformat/ffmdec.c
	libavformat/nutenc.c
	tests/ref/lavfi/crop
	tests/ref/lavfi/crop_scale
	tests/ref/lavfi/crop_scale_vflip
	tests/ref/lavfi/crop_vflip
	tests/ref/lavfi/null
	tests/ref/lavfi/pixdesc
	tests/ref/lavfi/pixfmts_copy
	tests/ref/lavfi/pixfmts_crop
	tests/ref/lavfi/pixfmts_hflip
	tests/ref/lavfi/pixfmts_null
	tests/ref/lavfi/pixfmts_pad
	tests/ref/lavfi/pixfmts_scale
	tests/ref/lavfi/pixfmts_vflip
	tests/ref/lavfi/scale200
	tests/ref/lavfi/scale500
	tests/ref/lavfi/vflip
	tests/ref/lavfi/vflip_crop
	tests/ref/lavfi/vflip_vflip

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-10-17 14:17:55 +02:00