MCPcopy Create free account
hub / github.com/codestation/qcma / getDecodedFrame

Method getDecodedFrame

common/avdecoder.cpp:137–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135}
136
137AVFrame *AVDecoder::getDecodedFrame(AVCodecContext *codec_ctx, int frame_stream_index)
138{
139 AVFrame *pFrame = av_frame_alloc();
140 AVPacket *packet = av_packet_alloc();
141 int ret = 0;
142
143 while (av_read_frame(pFormatCtx, packet) >= 0) {
144 if (packet->stream_index == frame_stream_index) {
145 ret = avcodec_send_packet(codec_ctx, packet);
146 av_packet_unref(packet);
147 if (ret < 0) {
148 break;
149 }
150 ret = avcodec_receive_frame(codec_ctx, pFrame);
151 if (ret == 0) {
152 // Frame successfully decoded
153 av_packet_free(&packet);
154 return pFrame;
155 } else if (ret == AVERROR(EAGAIN)) {
156 // Need more packets
157 continue;
158 } else {
159 // Error or end of stream
160 break;
161 }
162 } else {
163 av_packet_unref(packet);
164 }
165 }
166
167 av_packet_free(&packet);
168 av_frame_free(&pFrame);
169 return NULL;
170}
171
172
173bool AVDecoder::seekVideo(int percentage)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected