typedef struct TiffContext {
AVCodecContext *avctx;
GetByteContext gb;
- AVFrame picture;
int width, height;
unsigned int bpp, bppcount;
static int add_doubles_metadata(int count,
const char *name, const char *sep,
- TiffContext *s)
+ TiffContext *s, AVFrame *frame)
{
char *ap;
int i;
av_freep(&dp);
if (!ap)
return AVERROR(ENOMEM);
- av_dict_set(avpriv_frame_get_metadatap(&s->picture), name, ap, AV_DICT_DONT_STRDUP_VAL);
+ av_dict_set(avpriv_frame_get_metadatap(frame), name, ap, AV_DICT_DONT_STRDUP_VAL);
return 0;
}
static int add_shorts_metadata(int count, const char *name,
- const char *sep, TiffContext *s)
+ const char *sep, TiffContext *s, AVFrame *frame)
{
char *ap;
int i;
av_freep(&sp);
if (!ap)
return AVERROR(ENOMEM);
- av_dict_set(avpriv_frame_get_metadatap(&s->picture), name, ap, AV_DICT_DONT_STRDUP_VAL);
+ av_dict_set(avpriv_frame_get_metadatap(frame), name, ap, AV_DICT_DONT_STRDUP_VAL);
return 0;
}
static int add_string_metadata(int count, const char *name,
- TiffContext *s)
+ TiffContext *s, AVFrame *frame)
{
char *value;
bytestream2_get_bufferu(&s->gb, value, count);
value[count] = 0;
- av_dict_set(avpriv_frame_get_metadatap(&s->picture), name, value, AV_DICT_DONT_STRDUP_VAL);
+ av_dict_set(avpriv_frame_get_metadatap(frame), name, value, AV_DICT_DONT_STRDUP_VAL);
return 0;
}
static int add_metadata(int count, int type,
- const char *name, const char *sep, TiffContext *s)
+ const char *name, const char *sep, TiffContext *s, AVFrame *frame)
{
switch(type) {
- case TIFF_DOUBLE: return add_doubles_metadata(count, name, sep, s);
- case TIFF_SHORT : return add_shorts_metadata(count, name, sep, s);
- case TIFF_STRING: return add_string_metadata(count, name, s);
+ case TIFF_DOUBLE: return add_doubles_metadata(count, name, sep, s, frame);
+ case TIFF_SHORT : return add_shorts_metadata(count, name, sep, s, frame);
+ case TIFF_STRING: return add_string_metadata(count, name, s, frame);
default : return AVERROR_INVALIDDATA;
};
}
return 0;
}
-static int tiff_decode_tag(TiffContext *s)
+static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
{
unsigned tag, type, count, off, value = 0;
int i, j, k, pos, start;
s->fax_opts = value;
break;
#define ADD_METADATA(count, name, sep)\
- if ((ret = add_metadata(count, type, name, sep, s)) < 0) {\
+ if ((ret = add_metadata(count, type, name, sep, s, frame)) < 0) {\
av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");\
return ret;\
}
s->compr = TIFF_RAW;
s->fill_order = 0;
free_geotags(s);
- /* metadata has been destroyed from lavc internals, that pointer is not
- * valid anymore */
- av_frame_set_metadata(p, NULL);
// As TIFF 6.0 specification puts it "An arbitrary but carefully chosen number
// that further identifies the file as a TIFF file"
if (bytestream2_get_bytes_left(&s->gb) < entries * 12)
return AVERROR_INVALIDDATA;
for (i = 0; i < entries; i++) {
- if ((ret = tiff_decode_tag(s)) < 0)
+ if ((ret = tiff_decode_tag(s, p)) < 0)
return ret;
}
av_log(avctx, AV_LOG_WARNING, "Type of GeoTIFF key %d is wrong\n", s->geotags[i].key);
continue;
}
- ret = av_dict_set(avpriv_frame_get_metadatap(&s->picture), keyname, s->geotags[i].val, 0);
+ ret = av_dict_set(avpriv_frame_get_metadatap(p), keyname, s->geotags[i].val, 0);
if (ret<0) {
av_log(avctx, AV_LOG_ERROR, "Writing metadata with key '%s' failed\n", keyname);
return ret;