87 if (pkt->duration < 0 && st->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE) {
90 "Packet with invalid duration %" PRId64 " in stream %d\n",
100 switch (st->codecpar->codec_type) {
101 case AVMEDIA_TYPE_VIDEO:
102 if (st->avg_frame_rate.num > 0 && st->avg_frame_rate.den > 0) {
103 pkt->duration = av_rescale_q(1, av_inv_q(st->avg_frame_rate), st->time_base);
105 else if (st->time_base.num * 1000LL > st->time_base.den) {
109 case AVMEDIA_TYPE_AUDIO: {
110 int frame_size = av_get_audio_frame_duration2(st->codecpar, pkt->size);
111 if (frame_size && st->codecpar->sample_rate) {
112 pkt->duration = av_rescale_q(
113 frame_size, (AVRational){1, st->codecpar->sample_rate}, st->time_base);
173#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(60, 29, 100)
174 const AVPacketSideData *src_matrix = av_packet_side_data_get(src->codecpar->coded_side_data,
175 src->codecpar->nb_coded_side_data,
176 AV_PKT_DATA_DISPLAYMATRIX);
177 if (src_matrix !=
nullptr) {
178 uint8_t *dst_matrix = (uint8_t *)av_memdup(src_matrix->data, src_matrix->size);
179 av_packet_side_data_add(&dst->codecpar->coded_side_data,
180 &dst->codecpar->nb_coded_side_data,
181 AV_PKT_DATA_DISPLAYMATRIX,
191#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(60, 29, 100)
192 const AVPacketSideData *src_matrix = av_packet_side_data_get(
193 stream->codecpar->coded_side_data,
194 stream->codecpar->nb_coded_side_data,
195 AV_PKT_DATA_DISPLAYMATRIX);
196 if (src_matrix !=
nullptr) {
199 double theta = -av_display_rotation_get((
const int32_t *)src_matrix->data);