Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* find the video decoder */
- if (!(pCodec=avcodec_find_decoder_by_name("h264_mediacodec"))){ //first find the h264_mediacodec
- LOGD("h264_mediacodec not found, using h264");
- if (!(pCodec=avcodec_find_decoder(AV_CODEC_ID_H264))){ //AV_CODEC_ID_H264 AV_CODEC_ID_HEVC
- LOGD("codec not found!");
- goto ERROR;
- }
- }
- else
- LOGD("using h264_mediacodec");
- pCodecCtx = avcodec_alloc_context3(pCodec);
- /*pCodecCtx->codec_type = AVMEDIA_TYPE_VIDEO;
- pCodecCtx->codec_id = AV_CODEC_ID_H264;
- pCodecCtx->profile = FF_PROFILE_H264_MAIN;
- pCodecCtx->coded_width = 1280;
- pCodecCtx->coded_height = 720;
- pCodecCtx->pix_fmt = AV_PIX_FMT_YUV420P;
- pCodecCtx->extradata = NULL;
- pCodecCtx->extradata_size = 0;*/
- av_opt_set_int(pCodecCtx, "refcounted_frames", 1, 0);
- av_opt_set(pCodecCtx, "threads", "auto", 0);
- pCodecCtx->codec_id = AV_CODEC_ID_H264;
- pCodecCtx->get_format = mediacodec_hwaccel_get_format;
- pCodecCtx->thread_count = 1;
- pFrame = av_frame_alloc();// Allocate video frame
- if((pCodecCtx == NULL)||(pFrame == NULL))
- {
- LOGD("pCodecCtx or pFrame alloc fail");
- goto ERROR;
- }
- int ret = avcodec_open2(pCodecCtx, pCodec, NULL);
- if ( ret < 0) {
- LOGD("could not open codec %d", ret);
- goto ERROR;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement