| 128 | } |
| 129 | |
| 130 | static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, |
| 131 | AVPacket *avpkt) { |
| 132 | const uint8_t *buf = avpkt->data; |
| 133 | int buf_size = avpkt->size; |
| 134 | NuvContext *c = avctx->priv_data; |
| 135 | AVFrame *picture = data; |
| 136 | int orig_size = buf_size; |
| 137 | int keyframe; |
| 138 | int result; |
| 139 | enum {NUV_UNCOMPRESSED = '0', NUV_RTJPEG = '1', |
| 140 | NUV_RTJPEG_IN_LZO = '2', NUV_LZO = '3', |
| 141 | NUV_BLACK = 'N', NUV_COPY_LAST = 'L'} comptype; |
| 142 | |
| 143 | if (buf_size < 12) { |
| 144 | av_log(avctx, AV_LOG_ERROR, "coded frame too small\n"); |
| 145 | return -1; |
| 146 | } |
| 147 | |
| 148 | // codec data (rtjpeg quant tables) |
| 149 | if (buf[0] == 'D' && buf[1] == 'R') { |
| 150 | int ret; |
| 151 | // skip rest of the frameheader. |
| 152 | buf = &buf[12]; |
| 153 | buf_size -= 12; |
| 154 | ret = get_quant(avctx, c, buf, buf_size); |
| 155 | if (ret < 0) |
| 156 | return ret; |
| 157 | rtjpeg_decode_init(&c->rtj, &c->dsp, c->width, c->height, c->lq, c->cq); |
| 158 | return orig_size; |
| 159 | } |
| 160 | |
| 161 | if (buf[0] != 'V' || buf_size < 12) { |
| 162 | av_log(avctx, AV_LOG_ERROR, "not a nuv video frame\n"); |
| 163 | return -1; |
| 164 | } |
| 165 | comptype = buf[1]; |
| 166 | switch (comptype) { |
| 167 | case NUV_RTJPEG_IN_LZO: |
| 168 | case NUV_RTJPEG: |
| 169 | keyframe = !buf[2]; break; |
| 170 | case NUV_COPY_LAST: |
| 171 | keyframe = 0; break; |
| 172 | default: |
| 173 | keyframe = 1; break; |
| 174 | } |
| 175 | // skip rest of the frameheader. |
| 176 | buf = &buf[12]; |
| 177 | buf_size -= 12; |
| 178 | if (comptype == NUV_RTJPEG_IN_LZO || comptype == NUV_LZO) { |
| 179 | int outlen = c->decomp_size, inlen = buf_size; |
| 180 | if (av_lzo1x_decode(c->decomp_buf, &outlen, buf, &inlen)) |
| 181 | av_log(avctx, AV_LOG_ERROR, "error during lzo decompression\n"); |
| 182 | buf = c->decomp_buf; |
| 183 | buf_size = c->decomp_size; |
| 184 | } |
| 185 | if (c->codec_frameheader) { |
| 186 | int w, h, q; |
| 187 | if (buf_size < 12) { |
nothing calls this directly
no test coverage detected