| 136 | } |
| 137 | |
| 138 | static int ir2_decode_frame(AVCodecContext *avctx, |
| 139 | void *data, int *data_size, |
| 140 | AVPacket *avpkt) |
| 141 | { |
| 142 | const uint8_t *buf = avpkt->data; |
| 143 | int buf_size = avpkt->size; |
| 144 | Ir2Context * const s = avctx->priv_data; |
| 145 | AVFrame *picture = data; |
| 146 | AVFrame * const p= (AVFrame*)&s->picture; |
| 147 | int start; |
| 148 | |
| 149 | if(p->data[0]) |
| 150 | avctx->release_buffer(avctx, p); |
| 151 | |
| 152 | p->reference = 1; |
| 153 | p->buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; |
| 154 | if (avctx->reget_buffer(avctx, p)) { |
| 155 | av_log(s->avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); |
| 156 | return -1; |
| 157 | } |
| 158 | |
| 159 | s->decode_delta = buf[18]; |
| 160 | |
| 161 | /* decide whether frame uses deltas or not */ |
| 162 | #ifndef ALT_BITSTREAM_READER_LE |
| 163 | for (i = 0; i < buf_size; i++) |
| 164 | buf[i] = av_reverse[buf[i]]; |
| 165 | #endif |
| 166 | start = 48; /* hardcoded for now */ |
| 167 | |
| 168 | init_get_bits(&s->gb, buf + start, buf_size - start); |
| 169 | |
| 170 | if (s->decode_delta) { /* intraframe */ |
| 171 | ir2_decode_plane(s, avctx->width, avctx->height, |
| 172 | s->picture.data[0], s->picture.linesize[0], ir2_luma_table); |
| 173 | /* swapped U and V */ |
| 174 | ir2_decode_plane(s, avctx->width >> 2, avctx->height >> 2, |
| 175 | s->picture.data[2], s->picture.linesize[2], ir2_luma_table); |
| 176 | ir2_decode_plane(s, avctx->width >> 2, avctx->height >> 2, |
| 177 | s->picture.data[1], s->picture.linesize[1], ir2_luma_table); |
| 178 | } else { /* interframe */ |
| 179 | ir2_decode_plane_inter(s, avctx->width, avctx->height, |
| 180 | s->picture.data[0], s->picture.linesize[0], ir2_luma_table); |
| 181 | /* swapped U and V */ |
| 182 | ir2_decode_plane_inter(s, avctx->width >> 2, avctx->height >> 2, |
| 183 | s->picture.data[2], s->picture.linesize[2], ir2_luma_table); |
| 184 | ir2_decode_plane_inter(s, avctx->width >> 2, avctx->height >> 2, |
| 185 | s->picture.data[1], s->picture.linesize[1], ir2_luma_table); |
| 186 | } |
| 187 | |
| 188 | *picture= *(AVFrame*)&s->picture; |
| 189 | *data_size = sizeof(AVPicture); |
| 190 | |
| 191 | return buf_size; |
| 192 | } |
| 193 | |
| 194 | static av_cold int ir2_decode_init(AVCodecContext *avctx){ |
| 195 | Ir2Context * const ic = avctx->priv_data; |
nothing calls this directly
no test coverage detected