2 * Copyright 2012 Michael Chen <omxcodec@gmail.com>
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef FFMPEG_UTILS_H_
19 #define FFMPEG_UTILS_H_
24 #include <utils/Errors.h>
31 #include "libavformat/avformat.h"
32 #include "libavcodec/avcodec.h"
34 #include "libavutil/avstring.h"
35 #include "libavutil/colorspace.h"
36 #include "libavutil/mathematics.h"
37 #include "libavutil/pixdesc.h"
38 #include "libavutil/imgutils.h"
39 #include "libavutil/dict.h"
40 #include "libavutil/parseutils.h"
41 #include "libavutil/samplefmt.h"
42 #include "libavutil/avassert.h"
43 #include "libavformat/avformat.h"
44 #include "libavdevice/avdevice.h"
45 #include "libswscale/swscale.h"
46 #include "libavutil/opt.h"
47 #include "libavutil/internal.h"
48 #include "libavcodec/avfft.h"
49 #include "libavcodec/xiph.h"
50 #include "libswresample/swresample.h"
57 #define SF_NOPTS_VALUE ((uint64_t)AV_NOPTS_VALUE-1)
61 //////////////////////////////////////////////////////////////////////////////////
63 //////////////////////////////////////////////////////////////////////////////////
64 void nam_av_log_callback(void* ptr, int level, const char* fmt, va_list vl);
65 void nam_av_log_set_flags(int arg);
67 //////////////////////////////////////////////////////////////////////////////////
68 // constructor and destructor
69 //////////////////////////////////////////////////////////////////////////////////
70 status_t initFFmpeg();
73 //////////////////////////////////////////////////////////////////////////////////
75 //////////////////////////////////////////////////////////////////////////////////
76 int is_extradata_compatible_with_android(AVCodecContext *avctx);
77 int parser_split(AVCodecContext *avctx, const uint8_t *buf, int buf_size);
79 //////////////////////////////////////////////////////////////////////////////////
81 //////////////////////////////////////////////////////////////////////////////////
83 typedef struct PacketQueue {
85 AVPacketList *first_pkt, *last_pkt;
89 pthread_mutex_t mutex;
93 void packet_queue_init(PacketQueue *q);
94 void packet_queue_destroy(PacketQueue *q);
95 void packet_queue_flush(PacketQueue *q);
96 void packet_queue_end(PacketQueue *q);
97 void packet_queue_abort(PacketQueue *q);
98 int packet_queue_put(PacketQueue *q, AVPacket *pkt);
99 int packet_queue_put_nullpacket(PacketQueue *q, int stream_index);
100 int packet_queue_get(PacketQueue *q, AVPacket *pkt, int block);
102 //////////////////////////////////////////////////////////////////////////////////
104 //////////////////////////////////////////////////////////////////////////////////
105 bool setup_vorbis_extradata(uint8_t **extradata, int *extradata_size,
106 const uint8_t *header_start[3], const int header_len[3]);
108 } // namespace android
110 #endif // FFMPEG_UTILS_H_