summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
0735b50)
Since the conversion to refcounted frames, the tiff decoder
only wrote the metadata into its internal "picture" in its own context,
never exposing the metadata to the user, and eventually leaking the
metadata.
Instead, properly store the metadata directly into the frame being decoded into.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
typedef struct TiffContext {
AVCodecContext *avctx;
GetByteContext gb;
typedef struct TiffContext {
AVCodecContext *avctx;
GetByteContext gb;
int width, height;
unsigned int bpp, bppcount;
int width, height;
unsigned int bpp, bppcount;
static int add_doubles_metadata(int count,
const char *name, const char *sep,
static int add_doubles_metadata(int count,
const char *name, const char *sep,
+ TiffContext *s, AVFrame *frame)
av_freep(&dp);
if (!ap)
return AVERROR(ENOMEM);
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,
return 0;
}
static int add_shorts_metadata(int count, const char *name,
- const char *sep, TiffContext *s)
+ const char *sep, TiffContext *s, AVFrame *frame)
av_freep(&sp);
if (!ap)
return AVERROR(ENOMEM);
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,
return 0;
}
static int add_string_metadata(int count, const char *name,
+ TiffContext *s, AVFrame *frame)
bytestream2_get_bufferu(&s->gb, value, count);
value[count] = 0;
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,
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)
- 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;
};
}
default : return AVERROR_INVALIDDATA;
};
}
-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;
{
unsigned tag, type, count, off, value = 0;
int i, j, k, pos, start;
s->fax_opts = value;
break;
#define ADD_METADATA(count, name, sep)\
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;\
}
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);
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"
// 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 (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)
av_log(avctx, AV_LOG_WARNING, "Type of GeoTIFF key %d is wrong\n", s->geotags[i].key);
continue;
}
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;
if (ret<0) {
av_log(avctx, AV_LOG_ERROR, "Writing metadata with key '%s' failed\n", keyname);
return ret;