MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / imm5_decode_frame

Function imm5_decode_frame

libavcodec/imm5.c:85–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85static int imm5_decode_frame(AVCodecContext *avctx, AVFrame *frame,
86 int *got_frame, AVPacket *avpkt)
87{
88 IMM5Context *ctx = avctx->priv_data;
89 AVCodecContext *codec_avctx = ctx->h264_avctx;
90 int ret;
91
92 if (avpkt->size > 24 && avpkt->data[8] <= 1 && AV_RL32(avpkt->data + 4) + 24ULL <= avpkt->size) {
93 int codec_type = avpkt->data[1];
94 int index = avpkt->data[10];
95 int new_size = AV_RL32(avpkt->data + 4);
96 int offset, off;
97
98 if (codec_type == 0xA) {
99 codec_avctx = ctx->hevc_avctx;
100 } else if (index == 17) {
101 index = 4;
102 } else if (index == 18) {
103 index = 5;
104 }
105
106 if (index >= 1 && index <= 12) {
107 ret = av_packet_make_writable(avpkt);
108 if (ret < 0)
109 return ret;
110
111 index -= 1;
112 off = offset = IMM5_units[index].len;
113 if (codec_type == 2) {
114 offset += IMM5_units[12].len;
115 } else {
116 offset += IMM5_units[13].len;
117 }
118
119 avpkt->data += 24 - offset;
120 avpkt->size = new_size + offset;
121
122 memcpy(avpkt->data, IMM5_units[index].bits, IMM5_units[index].len);
123 if (codec_type == 2) {
124 memcpy(avpkt->data + off, IMM5_units[12].bits, IMM5_units[12].len);
125 } else {
126 memcpy(avpkt->data + off, IMM5_units[13].bits, IMM5_units[13].len);
127 }
128 } else {
129 avpkt->data += 24;
130 avpkt->size -= 24;
131 }
132 }
133
134 ret = avcodec_send_packet(codec_avctx, avpkt);
135 if (ret < 0) {
136 av_log(avctx, AV_LOG_ERROR, "Error submitting a packet for decoding\n");
137 return ret;
138 }
139
140 ret = avcodec_receive_frame(codec_avctx, frame);
141 if (ret == AVERROR(EAGAIN))
142 return avpkt->size;

Callers

nothing calls this directly

Calls 4

av_packet_make_writableFunction · 0.85
avcodec_send_packetFunction · 0.85
av_logFunction · 0.85
avcodec_receive_frameFunction · 0.85

Tested by

no test coverage detected