| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/filters/bitstream_converter.h" | 5 #include "media/filters/bitstream_converter.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "media/ffmpeg/ffmpeg_common.h" | 8 #include "media/ffmpeg/ffmpeg_common.h" |
| 9 | 9 |
| 10 namespace media { | 10 namespace media { |
| 11 | 11 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 LOG(ERROR) << "Converter improperly initialized."; | 45 LOG(ERROR) << "Converter improperly initialized."; |
| 46 return false; | 46 return false; |
| 47 } | 47 } |
| 48 | 48 |
| 49 uint8_t* converted_data = NULL; | 49 uint8_t* converted_data = NULL; |
| 50 int converted_size = 0; | 50 int converted_size = 0; |
| 51 | 51 |
| 52 if (av_bitstream_filter_filter(stream_filter_, stream_context_, NULL, | 52 if (av_bitstream_filter_filter(stream_filter_, stream_context_, NULL, |
| 53 &converted_data, &converted_size, | 53 &converted_data, &converted_size, |
| 54 packet->data, packet->size, | 54 packet->data, packet->size, |
| 55 packet->flags & PKT_FLAG_KEY) < 0) { | 55 packet->flags & AV_PKT_FLAG_KEY) < 0) { |
| 56 return false; | 56 return false; |
| 57 } | 57 } |
| 58 | 58 |
| 59 // av_bitstream_filter_filter() does not always allocate a new packet. | 59 // av_bitstream_filter_filter() does not always allocate a new packet. |
| 60 // If a new packet was allocated, then we need to modify the | 60 // If a new packet was allocated, then we need to modify the |
| 61 // |packet| to point to the new data, releasing its current payload | 61 // |packet| to point to the new data, releasing its current payload |
| 62 // if it has the authoritative reference. | 62 // if it has the authoritative reference. |
| 63 // | 63 // |
| 64 // TODO(ajwong): We're relying on the implementation behavior of | 64 // TODO(ajwong): We're relying on the implementation behavior of |
| 65 // av_free_packet() and the meaning of the |destruct| field in | 65 // av_free_packet() and the meaning of the |destruct| field in |
| 66 // AVPacket. Try to find a cleaner way to do this. | 66 // AVPacket. Try to find a cleaner way to do this. |
| 67 if (converted_data != packet->data) { | 67 if (converted_data != packet->data) { |
| 68 av_free_packet(packet); | 68 av_free_packet(packet); |
| 69 packet->data = converted_data; | 69 packet->data = converted_data; |
| 70 packet->size = converted_size; | 70 packet->size = converted_size; |
| 71 packet->destruct = av_destruct_packet; | 71 packet->destruct = av_destruct_packet; |
| 72 } | 72 } |
| 73 | 73 |
| 74 return true; | 74 return true; |
| 75 } | 75 } |
| 76 | 76 |
| 77 } // namespace media | 77 } // namespace media |
| OLD | NEW |