Reputation: 11
See the following code from https://ffmpeg.org/doxygen/trunk/frame_8c_source.html#l00622:
static void get_frame_defaults(AVFrame *frame)
{
memset(frame, 0, sizeof(*frame));
frame->pts =
frame->pkt_dts = AV_NOPTS_VALUE;
frame->best_effort_timestamp = AV_NOPTS_VALUE;
frame->duration = 0;
#if FF_API_PKT_DURATION
FF_DISABLE_DEPRECATION_WARNINGS
frame->pkt_duration = 0;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
#if FF_API_FRAME_PKT
FF_DISABLE_DEPRECATION_WARNINGS
frame->pkt_pos = -1;
frame->pkt_size = -1;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
frame->time_base = (AVRational){ 0, 1 };
frame->sample_aspect_ratio = (AVRational){ 0, 1 };
frame->format = -1; /* unknown */
frame->extended_data = frame->data;
frame->color_primaries = AVCOL_PRI_UNSPECIFIED;
frame->color_trc = AVCOL_TRC_UNSPECIFIED;
frame->colorspace = AVCOL_SPC_UNSPECIFIED;
frame->color_range = AVCOL_RANGE_UNSPECIFIED;
frame->chroma_location = AVCHROMA_LOC_UNSPECIFIED;
frame->flags = 0;
}
You can see the get_frame_defaults function is marked as static, so not callable from other files. The only way to initialize AVFrame is via av_frame_alloc (plus av_frame_unref and av_frame_move_ref which operated on already initialized AVFrame), which allocates AVFrame in heap.
So there are no native method to initialize non-dynamically-allocated AVFrame object.
By comparison, libavcodec has a similar function av_init_packet which is public, and can be called for AVPacket object created elsewhere (e.g. on stack).
Upvotes: 0
Views: 49