Skip to content

Commit

Permalink
Roll FFmpeg for M48
Browse files Browse the repository at this point in the history
Changes:
* av_free_packet => av_packet_unref
  The former is deprecated in upstream FFmpeg.
* Remove unnecessary uses of av_dup_packet().
* Use max_analyze_duration instead of max_analyze_duration2.
  The latter has been removed and was likely part of a transition process.
* Disable FF_API_CONVERGENCE_DURATION.
  In upstream FFmpeg, it enables deprecated attributes, causing the
  implicit copy constructor to fail due to a deprecation warning.
* Disable FF_API_AVPACKET_OLD_API to avoid spammy deprecation warnings
  in upstream FFmpeg.

BUG=551980

Review URL: https://codereview.chromium.org/1436943006

Cr-Commit-Position: refs/heads/master@{#359500}
  • Loading branch information
ddorwin authored and Commit bot committed Nov 13, 2015
1 parent 94a4f88 commit bc4d25d
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 24 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ deps = {
Var('chromium_git') + '/webm/libvpx.git' + '@' + '0941ff72a00732cea6750477edfe649348e699de',

'src/third_party/ffmpeg':
Var('chromium_git') + '/chromium/third_party/ffmpeg.git' + '@' + 'b1b22ffc6a5c809c41cc27910e3e8b479c15d3a2',
Var('chromium_git') + '/chromium/third_party/ffmpeg.git' + '@' + '3540f6b0097b03aae1f29e41d8d8433044ee8cdb',

'src/third_party/libjingle/source/talk':
Var('chromium_git') + '/external/webrtc/trunk/talk.git' + '@' + '54a2705b0cb5978dc4c6054bea2f02130a21d328', # commit position 10622
Expand Down
9 changes: 3 additions & 6 deletions media/base/media_file_checker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,21 @@ bool MediaFileChecker::Start(base::TimeDelta check_time) {
base::TimeDelta::FromSeconds(kMaxCheckTimeInSeconds));
do {
result = av_read_frame(glue.format_context(), &packet);
if (result < 0)
break;
result = av_dup_packet(&packet);
if (result < 0)
break;

std::map<int, AVCodecContext*>::const_iterator it =
stream_contexts.find(packet.stream_index);
if (it == stream_contexts.end()) {
av_free_packet(&packet);
av_packet_unref(&packet);
continue;
}
AVCodecContext* av_context = it->second;

int frame_decoded = 0;
if (av_context->codec_type == AVMEDIA_TYPE_AUDIO) {
// A shallow copy of packet so we can slide packet.data as frames are
// decoded; otherwise av_free_packet() will corrupt memory.
// decoded; otherwise av_packet_unref() will corrupt memory.
AVPacket temp_packet = packet;
do {
result = avcodec_decode_audio4(av_context, frame.get(), &frame_decoded,
Expand All @@ -99,7 +96,7 @@ bool MediaFileChecker::Start(base::TimeDelta check_time) {
if (result >= 0 && frame_decoded)
av_frame_unref(frame.get());
}
av_free_packet(&packet);
av_packet_unref(&packet);
} while (base::TimeTicks::Now() < deadline && read_ok && result >= 0);

return read_ok && (result == AVERROR_EOF || result >= 0);
Expand Down
2 changes: 1 addition & 1 deletion media/cast/test/fake_media_source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ void FakeMediaSource::DecodeAudio(ScopedAVPacket packet) {
AVFrame* avframe = av_frame_alloc();

// Make a shallow copy of packet so we can slide packet.data as frames are
// decoded from the packet; otherwise av_free_packet() will corrupt memory.
// decoded from the packet; otherwise av_packet_unref() will corrupt memory.
AVPacket packet_temp = *packet.get();

do {
Expand Down
15 changes: 11 additions & 4 deletions media/ffmpeg/ffmpeg_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,16 @@
// Include FFmpeg header files.
extern "C" {
// Disable deprecated features which result in spammy compile warnings. This
// list of defines must mirror those in the 'defines' section of the ffmpeg.gyp
// file or the headers below will generate different structures.
// None currently.
// list of defines must mirror those in the 'defines' section of BUILD.gn file &
// ffmpeg.gyp file or the headers below will generate different structures!
#define FF_API_CONVERGENCE_DURATION 0
// Upstream libavcodec/utils.c still uses the deprecated
// av_dup_packet(), causing deprecation warnings.
// The normal fix for such things is to disable the feature as below,
// but the upstream code does not yet compile with it disabled.
// (In this case, the fix is replacing the call with a new function.)
// In the meantime, we directly disable those warnings in the C file.
//#define FF_API_AVPACKET_OLD_API 0

// Temporarily disable possible loss of data warning.
// TODO(scherkus): fix and upstream the compiler warnings.
Expand Down Expand Up @@ -54,7 +61,7 @@ inline void ScopedPtrAVFree::operator()(void* x) const {

inline void ScopedPtrAVFreePacket::operator()(void* x) const {
AVPacket* packet = static_cast<AVPacket*>(x);
av_free_packet(packet);
av_packet_unref(packet);
delete packet;
}

Expand Down
4 changes: 2 additions & 2 deletions media/filters/audio_decoder_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class AudioDecoderTest : public testing::TestWithParam<DecoderTestData> {
EXPECT_EQ(GetParam().first_packet_pts, packet.pts);
start_timestamp_ = ConvertFromTimeBase(
reader_->GetAVStreamForTesting()->time_base, packet.pts);
av_free_packet(&packet);
av_packet_unref(&packet);

// Seek back to the beginning.
ASSERT_TRUE(reader_->SeekForTesting(start_timestamp_));
Expand Down Expand Up @@ -197,7 +197,7 @@ class AudioDecoderTest : public testing::TestWithParam<DecoderTestData> {
SetDiscardPadding(&packet, buffer, GetParam().samples_per_second);

// DecodeBuffer() shouldn't need the original packet since it uses the copy.
av_free_packet(&packet);
av_packet_unref(&packet);
DecodeBuffer(buffer);
}

Expand Down
9 changes: 4 additions & 5 deletions media/filters/audio_file_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ int AudioFileReader::Read(AudioBus* audio_bus) {
while (current_frame < audio_bus->frames() && continue_decoding &&
ReadPacket(&packet)) {
// Make a shallow copy of packet so we can slide packet.data as frames are
// decoded from the packet; otherwise av_free_packet() will corrupt memory.
// decoded from the packet; otherwise av_packet_unref() will corrupt memory.
AVPacket packet_temp = packet;
do {
// Reset frame to default values.
Expand Down Expand Up @@ -221,7 +221,7 @@ int AudioFileReader::Read(AudioBus* audio_bus) {

current_frame += frames_read;
} while (packet_temp.size > 0);
av_free_packet(&packet);
av_packet_unref(&packet);
}

// Zero any remaining frames.
Expand Down Expand Up @@ -257,11 +257,10 @@ bool AudioFileReader::ReadPacketForTesting(AVPacket* output_packet) {
}

bool AudioFileReader::ReadPacket(AVPacket* output_packet) {
while (av_read_frame(glue_->format_context(), output_packet) >= 0 &&
av_dup_packet(output_packet) >= 0) {
while (av_read_frame(glue_->format_context(), output_packet) >= 0) {
// Skip packets from other streams.
if (output_packet->stream_index != stream_index_) {
av_free_packet(output_packet);
av_packet_unref(output_packet);
continue;
}
return true;
Expand Down
2 changes: 1 addition & 1 deletion media/filters/audio_file_reader_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class AudioFileReaderTest : public testing::Test {
EXPECT_EQ(packet_md5_hashes_[j], md5_hash) << "j = " << j;
}

av_free_packet(&packet);
av_packet_unref(&packet);
}
ASSERT_TRUE(reader_->SeekForTesting(start_timestamp));
}
Expand Down
2 changes: 1 addition & 1 deletion media/filters/ffmpeg_aac_bitstream_converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ bool FFmpegAACBitstreamConverter::ConvertPacket(AVPacket* packet) {
av_packet_copy_props(&dest_packet, packet);

// Release the old packet.
av_free_packet(packet);
av_packet_unref(packet);
*packet = dest_packet; // Finally, replace the values in the input packet.

return true;
Expand Down
2 changes: 1 addition & 1 deletion media/filters/ffmpeg_demuxer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ void FFmpegDemuxer::Initialize(DemuxerHost* host,
// this does not increase the amount of data downloaded. The default value
// is 5 AV_TIME_BASE units (1 second each), which prevents some oddly muxed
// streams from being detected properly; this value was chosen arbitrarily.
format_context->max_analyze_duration2 = 60 * AV_TIME_BASE;
format_context->max_analyze_duration = 60 * AV_TIME_BASE;

// Open the AVFormatContext using our glue layer.
CHECK(blocking_thread_.Start());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ bool FFmpegH264ToAnnexBBitstreamConverter::ConvertPacket(AVPacket* packet) {
configuration_processed_ = true;

// At the end we must destroy the old packet.
av_free_packet(packet);
av_packet_unref(packet);
*packet = dest_packet; // Finally, replace the values in the input packet.

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ bool FFmpegH265ToAnnexBBitstreamConverter::ConvertPacket(AVPacket* packet) {
memcpy(dest_packet.data, &input_frame[0], input_frame.size());

// At the end we must destroy the old packet.
av_free_packet(packet);
av_packet_unref(packet);
*packet = dest_packet; // Finally, replace the values in the input packet.

return true;
Expand Down

0 comments on commit bc4d25d

Please sign in to comment.