Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: media/base/media_posix.cc

Issue 99160: Clean up FFmpeg media formats and switch to using av_get_bits_per_sample_format(). (Closed)
Patch Set: Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/base/media.h" 5 #include "media/base/media.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include <dlfcn.h> 9 #include <dlfcn.h>
10 10
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "media/filters/ffmpeg_common.h" 14 #include "media/filters/ffmpeg_common.h"
15 15
16 // We create stub references to dynamically loaded functions in ffmpeg 16 // We create stub references to dynamically loaded functions in ffmpeg
17 // for ease of linking. 17 // for ease of linking.
18 // 18 //
19 // TODO(ajwong): We need to find a more maintainable way to have this work. 19 // TODO(ajwong): We need to find a more maintainable way to have this work.
20 // Also, this code should really be in the ffmpeg wrapper, and not here 20 // Also, this code should really be in the ffmpeg wrapper, and not here
21 // in the media level. The concept of "weak symbols" looks like it might 21 // in the media level. The concept of "weak symbols" looks like it might
22 // be promising, but I don't quite understand it yet. 22 // be promising, but I don't quite understand it yet.
23 extern "C" { 23 extern "C" {
24 24
25 int (*av_get_bits_per_sample_format_ptr)(enum SampleFormat sample_fmt);
26 int av_get_bits_per_sample_format(enum SampleFormat sample_fmt) {
27 return av_get_bits_per_sample_format(sample_fmt);
28 }
29
25 void (*avcodec_init_ptr)(void) = NULL; 30 void (*avcodec_init_ptr)(void) = NULL;
26 void avcodec_init(void) { 31 void avcodec_init(void) {
27 avcodec_init_ptr(); 32 avcodec_init_ptr();
28 } 33 }
29 34
30 AVCodec* (*avcodec_find_decoder_ptr)(enum CodecID id) = NULL; 35 AVCodec* (*avcodec_find_decoder_ptr)(enum CodecID id) = NULL;
31 AVCodec* avcodec_find_decoder(enum CodecID id) { 36 AVCodec* avcodec_find_decoder(enum CodecID id) {
32 return avcodec_find_decoder_ptr(id); 37 return avcodec_find_decoder_ptr(id);
33 } 38 }
34 39
(...skipping 12 matching lines...) Expand all
47 return avcodec_alloc_frame_ptr(); 52 return avcodec_alloc_frame_ptr();
48 } 53 }
49 54
50 int (*avcodec_decode_audio2_ptr)(AVCodecContext* avctx, int16_t* samples, 55 int (*avcodec_decode_audio2_ptr)(AVCodecContext* avctx, int16_t* samples,
51 int* frame_size_ptr, const uint8_t* buf, 56 int* frame_size_ptr, const uint8_t* buf,
52 int buf_size) = NULL; 57 int buf_size) = NULL;
53 int avcodec_decode_audio2(AVCodecContext* avctx, int16_t* samples, 58 int avcodec_decode_audio2(AVCodecContext* avctx, int16_t* samples,
54 int* frame_size_ptr, 59 int* frame_size_ptr,
55 const uint8_t* buf, int buf_size) { 60 const uint8_t* buf, int buf_size) {
56 61
57 return avcodec_decode_audio2_ptr(avctx, samples, frame_size_ptr, buf, 62 return avcodec_decode_audio2_ptr(avctx, samples, frame_size_ptr, buf,
58 buf_size); 63 buf_size);
59 } 64 }
60 65
61 66
62 int (*avcodec_decode_video_ptr)(AVCodecContext* avctx, AVFrame* picture, 67 int (*avcodec_decode_video_ptr)(AVCodecContext* avctx, AVFrame* picture,
63 int* got_picture_ptr, const uint8_t* buf, 68 int* got_picture_ptr, const uint8_t* buf,
64 int buf_size) = NULL; 69 int buf_size) = NULL;
65 int avcodec_decode_video(AVCodecContext* avctx, AVFrame* picture, 70 int avcodec_decode_video(AVCodecContext* avctx, AVFrame* picture,
66 int* got_picture_ptr, const uint8_t* buf, 71 int* got_picture_ptr, const uint8_t* buf,
67 int buf_size) { 72 int buf_size) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 for (size_t i = 0; i < arraysize(libs) && libs[i] != NULL; ++i) { 162 for (size_t i = 0; i < arraysize(libs) && libs[i] != NULL; ++i) {
158 dlclose(libs[i]); 163 dlclose(libs[i]);
159 libs[i] = NULL; // Just to be safe. 164 libs[i] = NULL; // Just to be safe.
160 } 165 }
161 return false; 166 return false;
162 } 167 }
163 168
164 // TODO(ajwong): Extract this to somewhere saner, and hopefully 169 // TODO(ajwong): Extract this to somewhere saner, and hopefully
165 // autogenerate the bindings from the .def files. Having all this 170 // autogenerate the bindings from the .def files. Having all this
166 // code here is incredibly ugly. 171 // code here is incredibly ugly.
172 av_get_bits_per_sample_format_ptr =
173 reinterpret_cast<int (*)(enum SampleFormat)>(
174 dlsym(libs[FILE_LIBAVCODEC], "av_get_bits_per_sample_format"));
awong 2009/04/28 23:25:56 :-/ I really need to fix this. next week. next we
167 avcodec_init_ptr = 175 avcodec_init_ptr =
168 reinterpret_cast<void(*)(void)>( 176 reinterpret_cast<void(*)(void)>(
169 dlsym(libs[FILE_LIBAVCODEC], "avcodec_init")); 177 dlsym(libs[FILE_LIBAVCODEC], "avcodec_init"));
170 avcodec_find_decoder_ptr = 178 avcodec_find_decoder_ptr =
171 reinterpret_cast<AVCodec* (*)(enum CodecID)>( 179 reinterpret_cast<AVCodec* (*)(enum CodecID)>(
172 dlsym(libs[FILE_LIBAVCODEC], "avcodec_find_decoder")); 180 dlsym(libs[FILE_LIBAVCODEC], "avcodec_find_decoder"));
173 avcodec_thread_init_ptr = 181 avcodec_thread_init_ptr =
174 reinterpret_cast<int (*)(AVCodecContext*, int)>( 182 reinterpret_cast<int (*)(AVCodecContext*, int)>(
175 dlsym(libs[FILE_LIBAVCODEC], "avcodec_thread_init")); 183 dlsym(libs[FILE_LIBAVCODEC], "avcodec_thread_init"));
176 avcodec_open_ptr = 184 avcodec_open_ptr =
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 av_read_frame_ptr && 230 av_read_frame_ptr &&
223 231
224 av_malloc_ptr) { 232 av_malloc_ptr) {
225 return true; 233 return true;
226 } 234 }
227 235
228 return false; 236 return false;
229 } 237 }
230 238
231 } // namespace media 239 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698