Revision 6f85c592
chunker_streamer/chunker_streamer.c | ||
---|---|---|
208 | 208 |
{ |
209 | 209 |
int video_frame_size = 0; |
210 | 210 |
AVFrame *scaledFrame = NULL; |
211 |
AVFrame *pFrame2 = NULL; |
|
212 | 211 |
scaledFrame=avcodec_alloc_frame(); |
213 | 212 |
if(scaledFrame==NULL) { |
214 | 213 |
fprintf(stderr, "INIT: Memory error alloc video frame!!!\n"); |
... | ... | |
223 | 222 |
return -1; |
224 | 223 |
} |
225 | 224 |
|
226 |
if (pFrame->pkt_pts != AV_NOPTS_VALUE) { |
|
227 |
pFrame->pts = av_rescale_q(pFrame->pkt_pts, time_base, pCodecCtxEnc->time_base); |
|
228 |
} else { //try to figure out the pts //TODO: review this |
|
229 |
if (pFrame->pkt_dts != AV_NOPTS_VALUE) { |
|
230 |
pFrame->pts = av_rescale_q(pFrame->pkt_dts, time_base, pCodecCtxEnc->time_base); |
|
231 |
} |
|
232 |
} |
|
233 | 225 |
|
234 |
pFrame2 = preprocessFrame(pFrame); |
|
235 |
if (pFrame2) pFrame = pFrame2; |
|
236 | 226 |
|
237 | 227 |
if(pCodecCtx->height != pCodecCtxEnc->height || pCodecCtx->width != pCodecCtxEnc->width) { |
238 | 228 |
// static AVPicture pict; |
... | ... | |
257 | 247 |
if(pCodecCtxEnc->coded_frame->pts!=AV_NOPTS_VALUE) |
258 | 248 |
*target_pts = av_rescale_q(pCodecCtxEnc->coded_frame->pts, pCodecCtxEnc->time_base, time_base); |
259 | 249 |
else { //TODO: review this |
260 |
if(pFrame2) av_free(pFrame2); |
|
261 | 250 |
if(scaledFrame) av_free(scaledFrame); |
262 | 251 |
if(scaledFrame_buffer) av_free(scaledFrame_buffer); |
263 | 252 |
return -1; |
... | ... | |
283 | 272 |
#endif |
284 | 273 |
} |
285 | 274 |
|
286 |
if(pFrame2) av_free(pFrame2); |
|
287 | 275 |
if(scaledFrame) av_free(scaledFrame); |
288 | 276 |
if(scaledFrame_buffer) av_free(scaledFrame_buffer); |
289 | 277 |
return video_frame_size; |
... | ... | |
982 | 970 |
|
983 | 971 |
if(frameFinished) |
984 | 972 |
{ // it must be true all the time else error |
985 |
|
|
973 |
AVFrame *pFrame2 = NULL; |
|
974 |
|
|
986 | 975 |
frame->number = ++contFrameVideo; |
987 | 976 |
|
988 | 977 |
|
... | ... | |
1059 | 1048 |
pFrame->pict_type); |
1060 | 1049 |
addFrameToOutstream(&outstream[0], frame, video_outbuf); |
1061 | 1050 |
} |
1051 |
|
|
1052 |
if (pFrame->pkt_pts != AV_NOPTS_VALUE) { |
|
1053 |
pFrame->pts = av_rescale_q(pFrame->pkt_pts, pFormatCtx->streams[videoStream]->time_base, outstream[1].pCodecCtxEnc->time_base); |
|
1054 |
} else { //try to figure out the pts //TODO: review this |
|
1055 |
if (pFrame->pkt_dts != AV_NOPTS_VALUE) { |
|
1056 |
pFrame->pts = av_rescale_q(pFrame->pkt_dts, pFormatCtx->streams[videoStream]->time_base, outstream[1].pCodecCtxEnc->time_base); |
|
1057 |
} |
|
1058 |
} |
|
1059 |
|
|
1060 |
pFrame2 = preprocessFrame(pFrame); |
|
1061 |
if (pFrame2) pFrame = pFrame2; |
|
1062 |
|
|
1062 | 1063 |
for (i=1; i < 1 + qualitylevels + (indexchannel?1:0); i++) { |
1063 | 1064 |
video_frame_size = transcodeFrame(video_outbuf, video_outbuf_size, &target_pts, pFrame, pFormatCtx->streams[videoStream]->time_base, pCodecCtx, outstream[i].pCodecCtxEnc); |
1064 | 1065 |
if (video_frame_size <= 0) { |
... | ... | |
1110 | 1111 |
|
1111 | 1112 |
} |
1112 | 1113 |
} |
1114 |
if(pFrame2) av_free(pFrame2); |
|
1113 | 1115 |
} |
1114 | 1116 |
} |
1115 | 1117 |
} else if(packet.stream_index==audioStream) { |
Also available in: Unified diff