Merge commit 'e0ab5078a7d865f8f6fd6a6d3cbe0f380ead4a3d'
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 21 Jan 2014 20:26:13 +0000 (21:26 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 21 Jan 2014 20:26:13 +0000 (21:26 +0100)
* commit 'e0ab5078a7d865f8f6fd6a6d3cbe0f380ead4a3d':
  lavc: do not force the emu edge flag

Conflicts:
libavcodec/utils.c

There should be no such bugs in ffmpeg, but merging it anyway
as its safer.

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/utils.c

@@@ -1456,53 -1091,16 +1456,48 @@@ int attribute_align_arg avcodec_open2(A
              ret = AVERROR(EINVAL);
              goto free_and_end;
          }
 -    }
 -end:
 -    entangled_thread_counter--;
 -
 -    /* Release any user-supplied mutex. */
 -    if (lockmgr_cb) {
 -        (*lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE);
 -    }
 -    if (options) {
 -        av_dict_free(options);
 +        if (avctx->sub_charenc) {
 +            if (avctx->codec_type != AVMEDIA_TYPE_SUBTITLE) {
 +                av_log(avctx, AV_LOG_ERROR, "Character encoding is only "
 +                       "supported with subtitles codecs\n");
 +                ret = AVERROR(EINVAL);
 +                goto free_and_end;
 +            } else if (avctx->codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB) {
 +                av_log(avctx, AV_LOG_WARNING, "Codec '%s' is bitmap-based, "
 +                       "subtitles character encoding will be ignored\n",
 +                       avctx->codec_descriptor->name);
 +                avctx->sub_charenc_mode = FF_SUB_CHARENC_MODE_DO_NOTHING;
 +            } else {
 +                /* input character encoding is set for a text based subtitle
 +                 * codec at this point */
 +                if (avctx->sub_charenc_mode == FF_SUB_CHARENC_MODE_AUTOMATIC)
 +                    avctx->sub_charenc_mode = FF_SUB_CHARENC_MODE_PRE_DECODER;
 +
 +                if (avctx->sub_charenc_mode == FF_SUB_CHARENC_MODE_PRE_DECODER) {
 +#if CONFIG_ICONV
 +                    iconv_t cd = iconv_open("UTF-8", avctx->sub_charenc);
 +                    if (cd == (iconv_t)-1) {
 +                        av_log(avctx, AV_LOG_ERROR, "Unable to open iconv context "
 +                               "with input character encoding \"%s\"\n", avctx->sub_charenc);
 +                        ret = AVERROR(errno);
 +                        goto free_and_end;
 +                    }
 +                    iconv_close(cd);
 +#else
 +                    av_log(avctx, AV_LOG_ERROR, "Character encoding subtitles "
 +                           "conversion needs a libavcodec built with iconv support "
 +                           "for this codec\n");
 +                    ret = AVERROR(ENOSYS);
 +                    goto free_and_end;
 +#endif
 +                }
 +            }
 +        }
- #if FF_API_EMU_EDGE
-         /* force the emu edge flag on, since it's now always active */
-         avctx->flags |= CODEC_FLAG_EMU_EDGE;
- #endif
 +    }
 +end:
 +    ff_unlock_avcodec();
 +    if (options) {
 +        av_dict_free(options);
          *options = tmp;
      }