| 134 | } |
| 135 | |
| 136 | static int decode_frame(AVCodecContext *avctx, AVFrame *f, |
| 137 | int *got_frame, AVPacket *avpkt) |
| 138 | { |
| 139 | FrapsContext * const s = avctx->priv_data; |
| 140 | const uint8_t *buf = avpkt->data; |
| 141 | int buf_size = avpkt->size; |
| 142 | uint32_t header; |
| 143 | unsigned int version,header_size; |
| 144 | const uint32_t *buf32; |
| 145 | uint32_t *luma1,*luma2,*cb,*cr; |
| 146 | uint32_t offs[4]; |
| 147 | int i, j, ret, is_chroma; |
| 148 | const int planes = 3; |
| 149 | int is_pal; |
| 150 | uint8_t *out; |
| 151 | |
| 152 | if (buf_size < 4) { |
| 153 | av_log(avctx, AV_LOG_ERROR, "Packet is too short\n"); |
| 154 | return AVERROR_INVALIDDATA; |
| 155 | } |
| 156 | |
| 157 | header = AV_RL32(buf); |
| 158 | version = header & 0xff; |
| 159 | is_pal = buf[1] == 2 && version == 1; |
| 160 | header_size = (header & (1<<30))? 8 : 4; /* bit 30 means pad to 8 bytes */ |
| 161 | |
| 162 | if (version > 5) { |
| 163 | avpriv_report_missing_feature(avctx, "Fraps version %u", version); |
| 164 | return AVERROR_PATCHWELCOME; |
| 165 | } |
| 166 | |
| 167 | buf += header_size; |
| 168 | |
| 169 | if (is_pal) { |
| 170 | unsigned needed_size = avctx->width * avctx->height + 1024; |
| 171 | needed_size += header_size; |
| 172 | if (buf_size != needed_size) { |
| 173 | av_log(avctx, AV_LOG_ERROR, |
| 174 | "Invalid frame length %d (should be %d)\n", |
| 175 | buf_size, needed_size); |
| 176 | return AVERROR_INVALIDDATA; |
| 177 | } |
| 178 | } else if (version < 2) { |
| 179 | unsigned needed_size = avctx->width * avctx->height * 3; |
| 180 | if (version == 0) needed_size /= 2; |
| 181 | needed_size += header_size; |
| 182 | /* bit 31 means same as previous pic */ |
| 183 | if (header & (1U<<31)) { |
| 184 | *got_frame = 0; |
| 185 | return buf_size; |
| 186 | } |
| 187 | if (buf_size != needed_size) { |
| 188 | av_log(avctx, AV_LOG_ERROR, |
| 189 | "Invalid frame length %d (should be %d)\n", |
| 190 | buf_size, needed_size); |
| 191 | return AVERROR_INVALIDDATA; |
| 192 | } |
| 193 | } else { |
nothing calls this directly
no test coverage detected