- hnm->width = avio_rl16(pb);
- hnm->height = avio_rl16(pb);
- hnm->filesize = avio_rl32(pb);
+ width = avio_rl16(pb);
+ height = avio_rl16(pb);
+ avio_rl32(pb); // filesize
if (!(vst = avformat_new_stream(s, NULL)))
return AVERROR(ENOMEM);
vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codecpar->codec_id = AV_CODEC_ID_HNM4_VIDEO;
vst->codecpar->codec_tag = 0;
if (!(vst = avformat_new_stream(s, NULL)))
return AVERROR(ENOMEM);
vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codecpar->codec_id = AV_CODEC_ID_HNM4_VIDEO;
vst->codecpar->codec_tag = 0;
- vst->codecpar->width = hnm->width;
- vst->codecpar->height = hnm->height;
- vst->codecpar->extradata = av_mallocz(1);
+ vst->codecpar->width = width;
+ vst->codecpar->height = height;
+ if ((ret = ff_alloc_extradata(vst->codecpar, 1)) < 0)
+ return ret;
- vst->codecpar->extradata_size = 1;
- memcpy(vst->codecpar->extradata, &hnm->version, 1);
+ // TODO: find a better way to detect HNM4A
+ vst->codecpar->extradata[0] = width == 640 ? 0x4a : 0x40;
-static int hnm_read_close(AVFormatContext *s)
-{
- Hnm4DemuxContext *hnm = s->priv_data;
-
- if (hnm->vpkt.size > 0)
- av_packet_unref(&hnm->vpkt);
-
- return 0;
-}
-
-AVInputFormat ff_hnm_demuxer = {
+const AVInputFormat ff_hnm_demuxer = {
.name = "hnm",
.long_name = NULL_IF_CONFIG_SMALL("Cryo HNM v4"),
.priv_data_size = sizeof(Hnm4DemuxContext),
.read_probe = hnm_probe,
.read_header = hnm_read_header,
.read_packet = hnm_read_packet,
.name = "hnm",
.long_name = NULL_IF_CONFIG_SMALL("Cryo HNM v4"),
.priv_data_size = sizeof(Hnm4DemuxContext),
.read_probe = hnm_probe,
.read_header = hnm_read_header,
.read_packet = hnm_read_packet,