| 49 | } |
| 50 | |
| 51 | static int msp_read_header(AVFormatContext *s) |
| 52 | { |
| 53 | MSPContext * cntx = s->priv_data; |
| 54 | AVIOContext *pb = s->pb; |
| 55 | AVStream *st; |
| 56 | |
| 57 | st = avformat_new_stream(s, NULL); |
| 58 | if (!st) |
| 59 | return AVERROR(ENOMEM); |
| 60 | |
| 61 | st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; |
| 62 | st->codecpar->codec_id = avio_rl32(pb) == MKTAG('D', 'a', 'n', 'M') ? AV_CODEC_ID_RAWVIDEO : AV_CODEC_ID_MSP2; |
| 63 | |
| 64 | st->codecpar->width = avio_rl16(pb); |
| 65 | st->codecpar->height = avio_rl16(pb); |
| 66 | st->codecpar->format = AV_PIX_FMT_MONOBLACK; |
| 67 | |
| 68 | st->sample_aspect_ratio.num = avio_rl16(pb); |
| 69 | st->sample_aspect_ratio.den = avio_rl16(pb); |
| 70 | avio_skip(pb, 20); |
| 71 | |
| 72 | if (st->codecpar->codec_id == AV_CODEC_ID_RAWVIDEO) { |
| 73 | cntx->packet_size = av_image_get_buffer_size(st->codecpar->format, st->codecpar->width, st->codecpar->height, 1); |
| 74 | } else |
| 75 | cntx->packet_size = 2 * st->codecpar->height; |
| 76 | |
| 77 | if (cntx->packet_size <= 0) |
| 78 | return cntx->packet_size < 0 ? cntx->packet_size : AVERROR_INVALIDDATA; |
| 79 | |
| 80 | return 0; |
| 81 | } |
| 82 | |
| 83 | static int msp_read_packet(AVFormatContext *s, AVPacket *pkt) |
| 84 | { |
nothing calls this directly
no test coverage detected