diff --git a/ijkmedia/ijkplayer/android/pipeline/ffpipenode_android_mediacodec_vdec.c b/ijkmedia/ijkplayer/android/pipeline/ffpipenode_android_mediacodec_vdec.c index 93713923ee1e7fc39ea684b2571b4c951fb8b35b..2e7a27debff81cb9d4321454a5fcb02d46294082 100644 --- a/ijkmedia/ijkplayer/android/pipeline/ffpipenode_android_mediacodec_vdec.c +++ b/ijkmedia/ijkplayer/android/pipeline/ffpipenode_android_mediacodec_vdec.c @@ -447,7 +447,8 @@ static int feed_input_buffer(JNIEnv *env, IJKFF_Pipenode *node, int64_t timeUs, int size_data_size = 0; AVPacket *avpkt = &d->pkt_temp; size_data = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, &size_data_size); - if (size_data && size_data_size > AV_INPUT_BUFFER_PADDING_SIZE) { + // minimum avcC(sps,pps) = 7 + if (size_data && size_data_size >= 7) { int got_picture = 0; AVFrame *frame = av_frame_alloc(); AVDictionary *codec_opts = NULL; diff --git a/ios/IJKMediaPlayer/IJKMediaPlayer/ijkmedia/ijkplayer/ios/pipeline/IJKVideoToolBox.m b/ios/IJKMediaPlayer/IJKMediaPlayer/ijkmedia/ijkplayer/ios/pipeline/IJKVideoToolBox.m index ecdb43d6f6eca07c1cad5dde5536bb0a407a5c88..6fc94731550a5732dbaf99728e2166b0641819fc 100644 --- a/ios/IJKMediaPlayer/IJKMediaPlayer/ijkmedia/ijkplayer/ios/pipeline/IJKVideoToolBox.m +++ b/ios/IJKMediaPlayer/IJKMediaPlayer/ijkmedia/ijkplayer/ios/pipeline/IJKVideoToolBox.m @@ -760,7 +760,8 @@ static int decode_video(VideoToolBoxContext* context, AVCodecContext *avctx, AVP if (context->ffp->vtb_handle_resolution_change && context->codecpar->codec_id == AV_CODEC_ID_H264) { size_data = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, &size_data_size); - if (size_data && size_data_size > AV_INPUT_BUFFER_PADDING_SIZE) { + // avcC(sps,pps) of size, minimum is 7 + if (size_data && size_data_size > 7) { int got_picture = 0; AVFrame *frame = av_frame_alloc(); AVDictionary *codec_opts = NULL; @@ -770,7 +771,7 @@ static int decode_video(VideoToolBoxContext* context, AVCodecContext *avctx, AVP avcodec_parameters_to_context(new_avctx, context->codecpar); av_freep(&new_avctx->extradata); - new_avctx->extradata = av_mallocz(size_data_size); + new_avctx->extradata = av_mallocz(size_data_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!new_avctx->extradata) return AVERROR(ENOMEM); memcpy(new_avctx->extradata, size_data, size_data_size);